Skip to content

Instantly share code, notes, and snippets.

@donaldallen
Created April 13, 2016 19:11
Show Gist options
  • Save donaldallen/7db7e145e48f783281f923d53abc5357 to your computer and use it in GitHub Desktop.
Save donaldallen/7db7e145e48f783281f923d53abc5357 to your computer and use it in GitHub Desktop.
server {
listen [::]:80;
listen 80;
# listen on both hosts
server_name donaldallen.com www.donaldallen.com;
# and redirect to the https host (declared below)
# avoiding http://www -> https://www -> https:// chain.
return 301 https://www.donaldallen.com$request_uri;
}
server {
listen [::]:443 ssl;
listen 443 ssl;
# listen on the wrong host
server_name donaldallen.com;
include h5bp/directive-only/ssl.conf;
# and redirect to the non-www host (declared below)
return 301 https://www.donaldallen.com$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment