Apache: Subdomain Management
January 24, 2008 1:31 AM
Subscribe
Quick Apachefilter Question:
I have complete control over my setup. What is the best way to setup Apache to serve files from /home/domain.com/subdomains/of/level/arbitrary/an/ when an.arbitrary.level.of.subdomains.domain.com is requested? I cannot figure this simple one out for the life of me!
I'm using Apache 2 and have control over BIND, but I've already setup wildcard domains. Thankyou!
posted by PuGZ to computers & internet (8 comments total)
1 user marked this as a favorite
Something like this might work, but the final implementation is left as an exercise to the reader (i.e. I don't have the time to test this now...)
RewriteEngine on
RewriteMap sub prg:/usr/bin/subtopath.pl
RewriteCond %{HTTP_HOST} ^([^\.]+)\.mydomain\.net
RewriteRule ^/(.+)$ ${sub:%1}/$1 [L]
and the perl script something like:
#!/usr/bin/perl
$|++;
while(<>) {
if($_=~/(([^\.]+.)+)mydomain\.net/) {
print "/var/www/".join ( "/",reverse split /\./,$1)."/\n";
} else {
print "/var/www/default/\n";
}
}
>
The mod_rewrite documentation comes in really handy and probably has the answers you need to make this work.
posted by phax at 3:15 AM on January 24, 2008