Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Re: Wildcard subdomains based on subdirectories

$
0
0
It's a bit of a hack, probably better done with map, but it does the job. Let it inspire you to make it better :)

____server {
______listen 80;
______server_name .mydom.com;
______access_log logs/mydom.com.access.log main;
______error_log logs/mydom.com.error.log;
______if ($host ~ "^(w{3}\.)?(.*?)\.?mydom\.com$") { set $myuri $2; }
______if ($myuri = '') { set $myuri 'www'; }
______set $myroot '/dynhosts/$myuri';
______if ($myuri = 'www') { set $myroot '/dynhostsroot/'; }
______root $myroot;
______location / {
________index index.html index.htm;
________try_files $myroot $myroot/ =404;
______}
____}

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>