Skip to content

Instantly share code, notes, and snippets.

@bepvte
Created January 26, 2018 17:51
Show Gist options
  • Save bepvte/a9d9237352accfe8c3ea14c1fca9750d to your computer and use it in GitHub Desktop.
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
#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