Skip to content

Instantly share code, notes, and snippets.

@sherred
Created February 25, 2016 11:43
Show Gist options
  • Save sherred/815a0a81b99484bc4eac to your computer and use it in GitHub Desktop.
Save sherred/815a0a81b99484bc4eac to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name {{ server_name }};
return 301 https://$server_name$request_uri;
}
server {
server_name www.{{ server_name }};
return 301 https://{{ server_name }}$request_uri;
}
server {
listen 443 etc...
@sherred
Copy link
Author

sherred commented Feb 29, 2016

the above does all redirects to https://domainname. to redirect everything to https://www. do the following:

change both return 301 https://$server_name$request_uri; to return 301 https://www.$server_name$request_uri;

change server_name www.{{ server_name }}; to server_name {{ server_name }};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment