Search code examples
apachesubdomainwildcardwildcard-subdomainwildcard-mapping

Apache wildcard at domain level


I have few sites, and they all have identical setup on a single server. Now, instead of the separate configuration file for each of them in sites-enabled directory, I want to have a common file.

Idea is this:

www.abc.com should have /var/www/abc as DocumentRoot, www.xyz.com should have /var/www/xyz as DocumentRoot, etc.

All other parameteres like log files, contact emails etc should also have identical setup (abc.com should have [email protected] as admin email, xyz.com should have [email protected] as admin email etc).

I couldnt find any tutorial on how to backreference wildcards, etc.

regards,

JP


Solution

  • Aha. Found the solution. VirtualDocumentRoot is the answer.

    A single line like:

    VirtualDocumentRoot /var/www/%0
    

    does the job. Havent really figured the logs stuff but should be similar and easy.

    See https://serverfault.com/questions/182929/wildcard-subdomain-directory-names for a nice related thread.

    You gotta enable vhost_alias module for this. (sudo a2enmod vhost_alias on ubuntu).