Remove index.php from url nginx laravel
Видалення index.php з любої частини URL
server {
root /var/www/*** index index.php;
server_name mywebsite.com;
if ($request_uri ~* "^(.*/)index\.php/*(.*)")
{ return 301 $1$2; }
….
Приклад того, що буде з URL :
mywebsite.com/index.php => mywebsite.com/
mywebsite.com/index.php?q=query => mywebsite.com/?q=query
mywebsite.com/index.php/article => mywebsite.com/article
mywebsite.com/index.php/article/ => mywebsite.com/article/
mywebsite.com/folder/index.php => mywebsite.com/folder/
mywebsite.com/folder/index.php?q=query => mywebsite.com/folder/?q=query
mywebsite.com/folder/index.php/article => mywebsite.com/folder/article
mywebsite.com/folder/index.php/article/ => mywebsite.com/folder/article/
Редірект з index.php на /
if ($request_uri ~* "^/index\.php/*(.*)") {
return 301 /$1;
}
Приклади редіректів:
mywebsite.com/index.php => mywebsite.com/
mywebsite.com/index.php?q=query => mywebsite.com/?q=query
mywebsite.com/index.php/article => mywebsite.com/article
mywebsite.com/index.php/article/ => mywebsite.com/article/