# This config sets up dynamic vhosts in /srv/http/$domainname
# As the first VirtualHost directive Apache finds (the '0000' part being
# ordered first), it will match every site not otherwise specified.
# If you want more specific configuration, do it in another, later VirtualHost
# directive.

<VirtualHost *:80>
	ServerName default
	ServerAdmin root@localhost

	DocumentRoot /srv/http/default

	UseCanonicalName off

# mod_vhost_alias does not have a 'fall back to default' capability, which
# makes it fairly useless for most purposes.

# Thankfully, we can engineer that on our own from mod_rewrite primitives.

	RewriteEngine on

	RewriteRule ^(.+) /srv/http/default$1

	RewriteCond /srv/http/%{SERVER_NAME} -d [OR] # if dir
	RewriteCond /srv/http/%{SERVER_NAME} -l      # if symlink
	RewriteRule ^(.+) /srv/http/%{SERVER_NAME}%{REQUEST_URI}

	RewriteLog /var/log/apache2/rewrite.log
# Debugging:
#	RewriteLogLevel 9

	<Directory />
		Options FollowSymLinks Indexes MultiViews ExecCGI
		AllowOverride None
	</Directory>
	
# If you want to redirect default over to a different domain
#	<Directory /srv/http/default>
#		Redirect / http://whatever/
#	</Directory>

	ErrorLog /var/log/apache2/error.log

	LogLevel warn

	CustomLog /var/log/apache2/access.log combined

</VirtualHost>

