Skip to content

Instantly share code, notes, and snippets.

@cihangir
Created July 7, 2015 01:07
Show Gist options
  • Save cihangir/01ef1c52110836cead3c to your computer and use it in GitHub Desktop.
Save cihangir/01ef1c52110836cead3c to your computer and use it in GitHub Desktop.
Generic 301 re-direction
server {
# just a random port
listen 81;
# why we have 2 different if checks? because www redirector block catches
# all the requests, we should be more precise with the host
# redirect http://kodingen.com to https://koding.com
if ($host = "kodingen.com") {
return 301 https://koding.com;
}
# redirect http://www.kodingen.com to https://koding.com
if ($host = "www.kodingen.com") {
return 301 https://koding.com;
}
# use generic names, do not hardcode values
return 301 https://$host$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment