Skip to content

Instantly share code, notes, and snippets.

@Rajeshr34
Last active November 23, 2017 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rajeshr34/f64500720cebf236eace1a4a1677db73 to your computer and use it in GitHub Desktop.
Save Rajeshr34/f64500720cebf236eace1a4a1677db73 to your computer and use it in GitHub Desktop.
Nginx Redirect www to non WWW
#Main Domain
#https?://www.example.com;
server {
listen 80;
server_name ~^www\.(?<dname>\w+)\.(?<dtype>\w+)$;
return 301 $scheme://$dname.$dtype$request_uri;
}
#Sub Domains if in case
#https?://www.chat.example.com;
server {
listen 80;
server_name ~^www\.(?<name>\w+)\.(?<dname>\w+)\.(?<dtype>\w+)$;
return 301 $scheme://$name.$dname.$dtype$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment