Created
September 26, 2017 09:56
-
-
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
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
# 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