Skip to content

Instantly share code, notes, and snippets.

@thomasruiz
Last active January 27, 2016 13:44
Show Gist options
  • Save thomasruiz/d9b791627d3d3795a3c6 to your computer and use it in GitHub Desktop.
Save thomasruiz/d9b791627d3d3795a3c6 to your computer and use it in GitHub Desktop.
redirect all http requests and www.* requests to https://host.name/ (from @jaw-sh)
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443;
listen [::]:443;
server_name "~^www\.(.*)$" ;
return 301 https://$1$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment