Apache wildcard documentroot

apache-2.2documentrootdomain-name-system

I would like to use the the subdomain as my DocumentRoot folder

foo.example.com 

Goes to

/var/www/foo

However I do not want to add a new entry for every subdomain

Basically

*.example.com

Goes to

/var/www/*

Where * is any alphanum string

Best Answer

VirtualDocumentRoot should do it.

<VirtualHost *:80>
    ServerName placeholdername
    ServerAlias *.example.com
    VirtualDocumentRoot /var/www/%1
</VirtualHost>
Related Topic