Forked from slow-is-fast/laravel remove index.php from url.md
Last active
February 11, 2021 19:43
-
-
Save mtx-z/ee0f7fc4783518a7e3e9d4630e2569a4 to your computer and use it in GitHub Desktop.
[nginx] laravel remove index.php from url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment