Somehow, I've never came across vhost_alias_module until now.
If you're like us and have dev/stage/prod environments where one of the only httpd conf changes is the (sub)domain, writing a VirtualHost directive 3+ times can become a pain.
Enter vhost_alias_module, a super simple solution to this problem.
Suppose your dev box has the following folders in
e9p.riker.e9p.net ep_accounting.riker.e9p.net odaa.riker.e9p.net preso.riker.e9p.net wishliz.riker.e9p.net
And the matching set in
000-catchall.conf 000-php.conf 005-e9p.riker.e9p.net.conf 005-ep_accounting.riker.e9p.net.conf 005-odaa.riker.e9p.net.conf 005-preso.riker.e9p.net.conf 005-wishliz.riker.e9p.net.conf
We can get rid of all those includes by adding a small change to
httpd.conf. Rather than including
conf.d/*.conf, we add the lines:
UseCanonicalName Off VirtualDocumentRoot /var/www/html/%0/docroot
Now, anytime someone visits
e9p.riker.e9p.net, apache will automatically map that to
This can easily be repeated to suffice on a staging box as well. I haven't tested the performance so have opted for the normal configuration on production, but it would work the same by changing the directory name to the live domain name.
There's a bunch more options other than just
%0, take a look at the apache documentation here.