goldfisch.at-knowledgebase   (by peter pilsl)


  vhost_alias gives troubles

keywords : VirtualDocumenRoot VirtualHost

If you use mod_vhost_alias with VirtualDocumentRoot and Standard <VirtualHost>-Definitions you might find that either one or the other will work but not both.

Imho the vhost_alias-docs are not clear on how to put the VirtualDocumentRoot-Statement.

Here how things work for me:

1) Just do all your <VirtualHost>-Stuff for all explicit VirtualHosts you have on your machine
2) Then add an extra <VirtualHost> !!*before*!! all the others. Give it a Servername that does not exist !! (ie. "ServerName not.a.host")
3) If apache does not find a suitable VirtualHost it will take the first one in its config, which now is our not.a.host.
4) Inside this VirtualHost we now put our VirtualDocumentRoot-config !!


example:


NameVirtualHost a.b.c.d:80

<VirtualHost a.b.c.d:80>
ServerName not.a.host
VirtualDocumentRoot /data/apache2/virtual/%0/
</VirtualHost>


NameVirtualHost a.b.c.d:80

<VirtualHost a.b.c.d:80>
ServerName my.domain.com
VirtualDocumentRoot /data/apache2/stopdeportation
</VirtualHost>


peter at 2009-11-24 (updated 2009-11-24)

serial : 459


If you found any nonsense in this entry or want to see important improvements, I would appreatiate to receive your comments at knowledge@goldfisch.at

disclaimer : all these entries are part of my very private knowledgebase that I created while solving problems. Many solutions are taken from other webpages or from usenet. There is no warranty for this entries of course. Some of the articles are even stupid and one day you might even find the name of my prefered pizza-service in here, cause I always forget about it. Remember : This is my knowledgebase. If you need professional support and are willing to pay for it just email me at pilsl@goldfisch.at
For enlightment take a look at http://leblogsportif.sportnation.at