I'm new to Apache, and I'm wondering if there's a way to configure
VirtualDocumentRoot to create an exception for just one of my vhosts on my local server. Currently all of my sites are stored in folders with the convention
httpd.conf I'm dynamically setting
VirtualDocumentRoot based on the server name:
# get the server name from the Host: header UseCanonicalName Off LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon CustomLog /path/to/logs/access.log vcommon ErrorLog /path/to/logs/errors.log VirtualDocumentRoot /path/to/vhosts/%0
This works great for all of my sites with one exception... the document root for one of the sites should point to
exception.dev/src/php instead of just
According to the answer I found here, it sounds as if
VirtualDocumentRoot cannot be set based on a conditional. So I was hoping my problem could be resolved by setting an alias of some sort to point
exception.dev to the right directory.
I've tried adding
VirtualScriptAlias, but this prevents the Apache server from starting:
VirtualScriptAlias /path/to/vhosts/exception.dev /path/to/vhosts/exception.dev/src/php
I've also tried the same type of thing with
ScriptAlias and just
Alias, but still no luck.
Is there something I'm missing here? Or is what I'm trying to do impossible? Any help would be greatly appreciated!
Oh, and if it helps, here's my output if I run
httpd: Could not reliably determine the server's fully qualified domain name, using XXXXX.local for ServerName VirtualHost configuration: Syntax OK
UPDATE: I got this to work by modifying Shane's answer below as follows:
NameVirtualHost * <VirtualHost *:80> ServerName exception.dev DocumentRoot /path/to/vhosts/exception.dev/src/php </VirtualHost> <VirtualHost *:80> ServerName default ServerAlias *.dev VirtualDocumentRoot /path/to/vhosts/%0 </VirtualHost>