# Remove index.php$
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
# Remove from everywhere index.php
if ($request_uri ~* "^(.*/)index\.php(/?)(.*)") {
return 301 $1$3;
}
}
# Remove trailing slash.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# Clean Double Slashes
if ($request_uri ~* "\/\/") {
rewrite ^/(.*) /$1 permanent;
}
Last active
February 24, 2025 17:31
-
-
Save slow-is-fast/68db4535780d6b46a8a8c777c1f2ba7a to your computer and use it in GitHub Desktop.
[nginx] laravel remove index.php from url
Where shall we put it?
I am getting "domain.com/index.php/slug"
I am on lighttpd server.
# Remove index.php$
if ($request_uri ~* "^(.*/)index\.php/*(.*)") {
return 301 $1$2;
}
I cant login phpmyadmin with this code, stuck at login screen. domain.com/phpmyadmin.
Thanks, it worked for me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the solution, but you might have url like
domain.com/index.php/slug
, to solve this: