Skip to content

Instantly share code, notes, and snippets.

@ChrisWelsh-mis
Created November 5, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisWelsh-mis/bf8ffab1487beef9be904de7a692e6ea to your computer and use it in GitHub Desktop.
Save ChrisWelsh-mis/bf8ffab1487beef9be904de7a692e6ea to your computer and use it in GitHub Desktop.
NGINX tips
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