In my Apache (Xampp) httpd-vhosts.conf
file I have added this Virtualhost
It allows me to use Wildcard names like testserver1.dev
and testserver2.dev
I just have to make sure to add the name to my Windows Hosts file.
<VirtualHost *:80>
VirtualDocumentRoot E:/Server/htdocs/projects/%1/www
ServerAlias *.dev
</VirtualHost>
What I would like to do though is add to this funtionality and make it work if the name begins with a www
so testserver1.dev
would also work as www.testserver1.dev
The way it currently is set up, if I tried to access that URL, it would look in a folder called www.testserver1
instead of the folder testserver1
Get rid of the ServerAlias and change the %1 to %-2.
As explained in the Directory Name Interpolation section of the mod_vhost_alias documentation, the
%-2
will tell Apache to look at the second from the last part of the name.The next section in the linked document has examples, one of which is the following:
Which will allow
www.example.com
as well aswww.sub.example.com
orexample.com
to serve files from/usr/local/apache/vhosts/example.com
. It does this as follows: