[Gllug] Apache V hosts

Steve Nicholson yahoogroups at yoursolutions.com
Tue Oct 7 12:13:55 UTC 2003


On Tue, 2003-10-07 at 11:33, Luke Hopkins wrote:
> I need to add some apache vhosts who all read from the same directory
> (database connections are dependand on the subdomain).
> 
> I currently have:
> <VirtualHost *>
>     ServerAdmin luke at domain.com
>     DocumentRoot /home/sites/home/web
>     ServerName sub1.domain.com
> </VirtualHost>
> <VirtualHost *>
>     ServerAdmin luke at domain.com
>     DocumentRoot /home/sites/home/web
>     ServerName sub2.domain.com
> </VirtualHost>
> 
> <VirtualHost *>
>     ServerAdmin luke at domain.com
>     DocumentRoot /home/sites/home/web
>     ServerName sub3.domain.com
> </VirtualHost>
> 
> What happens when I browse to say sub3.domain.com is the servername (php
> $SERVER_NAME) is sub1.domain.com because that's at the top of the list. 
> Any ideas how I get it to return the correct subdomain without having to
> use different directories (and preferably avoiding rewrites)?

I've recently been playing with this and had same problems, make sure
you have 
NameVirtualHost *

if this is a hostname or IP address and all the VirtualHost directives
are are * you won't get a match.

>From what I found you need to have matching NameVirtualHost IP's (or *)
and <VirtualHost IP's (or *)> directives.

e.g. 
NameVirtualHost *

<VirtualHost *>
....

otherwise a match isn't found and it defaults to the first one in the
list.

Steve.


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list