Skip to content

Instantly share code, notes, and snippets.

@denvers
Created September 26, 2017 09:56
Show Gist options
  • Save denvers/aa4ec8af71e3632604a8a11d68829eef to your computer and use it in GitHub Desktop.
Save denvers/aa4ec8af71e3632604a8a11d68829eef to your computer and use it in GitHub Desktop.
Nginx directives to firstly redirect to SSL and redirect to www-version if neccessary
# First redirect to https. Always before every other redirect according to https://internet.nl/test-site/
if ($scheme = http) {
return 301 https://www.$server_name$request_uri;
}
# Non-www to www redirect
if ($host !~* ^www\.) {
rewrite ^(.*)$ https://www.$host$1 permanent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment