Created
August 30, 2017 06:50
-
-
Save jerrylau91/19e04b3c2681a33bdbacfbb59da15b33 to your computer and use it in GitHub Desktop.
remove html extension and trailing slash with nginx
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
server { | |
listen 80; | |
server_name test.com *.test.com; | |
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent; | |
rewrite ^/(.*)/$ /$1 permanent; | |
root /path/to/project/root; | |
index index.html; | |
try_files $uri/index.html $uri.html $uri/ $uri =404; | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /500.html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use rewrite and try_files directives to achieve two goals, remove the html extension and the trailing slash.