I've managed to find a rewrite for making subdomains (which I have a wildcard domain pointed to my server; *.domain.com
.
If I go to test.domain.com
, it works just fine which transverse to:
/var/www/domain.com/www/test/
If I do example.test.domain.com
, it should do this:
/var/www/domain.com/www/test/example/
Which is another directory in the test
directory.
This is the rewrite I found to be used, but how should I implement the two directory subdomain in this?
if ($host !~* ^www\.domain\.domain$) {}
if ($host ~* ^([^.]+)\.domain\.com$) {
set $auto_subdomain $1;
}
if (-d /var/www/domain.com/www/$auto_subdomain) {}
if (-f /var/www/domain.com/www/$auto_subdomain$uri) {
rewrite ^(.*)$ /$auto_subdomain$uri;
break;
}
Try
/var/www/domain.com/www/example.test/
instead of/var/www/domain.com/www/test/example/
Update: Actually what you're trying to do is just a second vhost, nothing more. Why don't you try this nginx configuration?
And just create the directories for each domain/subdomain ie:
Source: http://wiki.nginx.org/VirtualHostExample
Also checkout this HOWTO from Slicehost regarding nginx vhosts http://articles.slicehost.com/2008/5/16/ubuntu-hardy-nginx-virtual-hosts
I don't think this will work with a wildcard subdomain. You should add a new zone for test.domain.com having inside *.test.domain.com
ref: http://en.wikipedia.org/wiki/Wildcard_DNS_record