Last active
August 29, 2015 14:11
-
-
Save AD7six/04d448f1cd335e218ab9 to your computer and use it in GitHub Desktop.
Don't think of doing this kind of thing on a live box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set $site $host; | |
# Strip www. prefix | |
if ($site ~ "^(w{3}\.)?(.*)$") { | |
set $site $2; | |
} | |
# Strip TLD prefix | |
if ($site ~ "^(.*)(\.[a-z]{3})$") { | |
set $site $1; | |
} | |
# Set webroot based on the domain name i.e. $site is `example` for the domain `www.example.dev` | |
set $webroot /var/www/$site/public; | |
# Webroot for this domain could not be found | |
if (!-d $webroot) { | |
set $webroot /var/www/default; | |
} | |
root $webroot; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment