Skip to content

Instantly share code, notes, and snippets.

@thomasfr
Created March 22, 2014 22:34
Show Gist options
  • Save thomasfr/9715456 to your computer and use it in GitHub Desktop.
Save thomasfr/9715456 to your computer and use it in GitHub Desktop.
Redirect all requests not matching server_name to `www.example.com`
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
rewrite ^ http://www.example.com permanent;
}
server {
server_name www.example.com
root /usr/share/nginx/html;
index index.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment