25 Ağustos 2020 07:36

Muslu Y.

JavaScript

SinglePage uygulamalarda (React - NextJS) anasayfayı gösterme sorunu

Anasayfa

JavaScript

SinglePage uygulamalarda (React - NextJS) anasayfa...

React, NextJS vs gibi tek sayfa (SinglePage Application) web sitelerinde sayfa url i manuel çağrıldığında veya sayfa yenilendiğinde otomatik anasayfaya gitmesini NGINX ile çözümü için aşağıdaki kodu eklemeniz yeterli.

 

NGINX

location / {
    index index.html;
    try_files $uri $uri/ /index.html?$args;
}
 
systemctl restart nginx
   
Apache

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
 
systemctl restart apache2
  Veya
systemctl restart httpd
  NOT: Test edilmedi ama çalışmalı

Makdos Bilişim Teknolojileri 2015 - 2025