Skip to content

Instantly share code, notes, and snippets.

@jbfavre
Created January 6, 2015 23:19
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 jbfavre/25a278dd65b2432030a9 to your computer and use it in GitHub Desktop.
Save jbfavre/25a278dd65b2432030a9 to your computer and use it in GitHub Desktop.
Nginx: using map to find root dir based on subdomain
map $http_host $dirname {
~(?P<subdomain>.*).domain.tld $subdomain;
}
server {
listen 80;
server_name domain.tld *.domain.tld;
root /var/www/$dirname/docroot;
index index.html;
try_files $uri $uri/ =404;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment