Created
November 5, 2017 16:17
-
-
Save ChrisWelsh-mis/bf8ffab1487beef9be904de7a692e6ea to your computer and use it in GitHub Desktop.
NGINX tips
This file contains hidden or 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
HTTP to HTTPS | |
return 301 https://$host$request_uri; | |
REDIRECT NON-WWW TO WWW: | |
if ( $host !~ ^www\. ) { | |
return 301 $scheme://www.$host$request_uri; | |
} | |
REDIRECT WWW TO NON-WWW | |
if ( $host ~ ^www\.(?<domain>.+)$ ) { | |
return 301 $scheme://$domain$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment