-
-
Save tannnt810/6db6620de7553f6b55919c9fda88a3dc to your computer and use it in GitHub Desktop.
Some of useful Nginx rewrite rules
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
// Nginx redirect non-www to www | |
server { | |
listen 80; | |
server_name domain.com; | |
rewrite ^/(.*)$ http://www.domain.com/$1 permanent; | |
} | |
server { | |
listen 80; | |
server_name www.domain.com; | |
// ... | |
// leave other settings here | |
} |
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
// Nginx redirect www to non-www | |
server { | |
listen 80; | |
server_name www.domain.com; | |
rewrite ^/(.*)$ http://domain.com/$1 permanent; | |
} | |
server { | |
listen 80; | |
server_name domain.com; | |
// ... | |
// leave other settings here | |
} |
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 .html | |
server { | |
rewrite ^(/.+)\.html$ $scheme://$host$1 permanent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment