Created
January 26, 2018 17:51
-
-
Save bepvte/a9d9237352accfe8c3ea14c1fca9750d to your computer and use it in GitHub Desktop.
the secret of how to remove the .html and trailing slash on nginx without redirect loops
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
#please ignore my indenting | |
location / { | |
try_files $uri $uri/ @htmlext; | |
} | |
location ~ \.html$ { | |
try_files $uri =404; | |
} | |
location @htmlext { | |
rewrite ^(.*)$ $1.html last; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment