Question

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 contact@abc.com as admin email, xyz.com should have contact@xyz.com as admin email etc).

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

regards,

JP

Was it helpful?

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top