Skip to content

Instantly share code, notes, and snippets.

@KitJacky
Created February 12, 2018 06:00
Show Gist options
  • Save KitJacky/91a622fc9d51d90906b3aad6f83748f0 to your computer and use it in GitHub Desktop.
Save KitJacky/91a622fc9d51d90906b3aad6f83748f0 to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name *.mydomain.com;
set $domain $host;
if ($domain ~ "^(w{3}\.)?(.*?)\.?mydomain.com") {
set $domain $2;
}
location / {
# forward *.mydomain.com/uri to mydomain.com/*/uri
return 301 $scheme://mydomain.com/$domain$request_uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment