WildCard Apache vHost

WildCard Apache vHost

Use this in combination with a wildcard domain on your server w/o bothering setting up each individual vHost. Tip: try log rotating, e.g. with Cronolog.

UseCanonicalName Off	
<VirtualHost *:80>
	ServerAdmin nobody@example.com
	ServerAlias *.example.com
	VirtualDocumentRoot /var/www/%1/public
	DirectoryIndex	index.php index.htm index.html

	<Directory /var/www/*/public/>
		AllowOverride	All
	</Directory>

	LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
	CustomLog /var/log/apache2/vhosts-access.log vcommon
	ErrorLog /var/log/apache2/vhosts-error.log
</VirtualHost>

Leave a Reply

Your email address will not be published. Required fields are marked *

four + 7 =