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
systemctl restart httpd
JavaScript
hakkında diğer konular