<VirtualHost 192.168.1.103:2800>
ServerName shoggoth.dyndns.biz
ServerAlias *.shoggoth.dyndns.biz
# get the server name from the Host: header
# UseCanonicalName Off
# splittable logs
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log vcommon
RewriteLogLevel 9
RewriteLog /var/log/apache2/rewrite.log
<Directory /www/hosts>
# ExecCGI is needed here because we can't force
# CGI execution in the way that ScriptAlias does
Options FollowSymLinks ExecCGI
</Directory>
# now for the hard bit
RewriteEngine On
# a ServerName derived from a Host: header may be any case at all
RewriteMap lowercase int:tolower
## deal with normal documents first:
# allow Alias /icons/ to work - repeat for other aliases
RewriteCond %{REQUEST_URI} !^/icons/
# allow CGIs to work
RewriteCond %{REQUEST_URI} !^/cgi-bin/
# do the magic
RewriteRule ^/(.*)$ /virtualhosts/${lowercase:%{SERVER_NAME}}/www/$1
## and now deal with CGIs - we have to force a MIME type
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteRule ^/(.*)$ /virtualhosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [T=application/x-httpd-cgi]
# that's it!
</VirtualHost>