[lug] Multiple Domains - Apache

Sean Reifschneider jafo at tummy.com
Mon Apr 28 18:20:50 MDT 2008


Deepan wrote:
 > However all requests to http://domainb.com/ gets
 > redirected to http://www.domaina.com  whereas the
 > expected behaviour is to get redirected to
 > http://www.domainb.com/ .

Why are you expecting that behavior?  You don't have a VirtualHost section
set up for handling "domainb.com", so it's being handled by the first
VirtualHost listed.

NameVirtualHost will only respond to requests for the listed server names
in the specified VirtualHost entry.  If a host name comes in that does not
match any of the listed names, it will be handled by the first VirtualHost.
The Apache documentation makes this clear.

So, it doesn't magically know that when you say "domainb.com" that you
actually mean "www.domainb.com".  You have to tell it what you want to have
happen.  So, in addition to the "ServerName www.domaina.com" you will want
to add a "ServerAlias domaina.com", so that the NameVirtualHost understands
both these names.

See the Apache documentation for ServerAlias for more information.

Sean
-- 
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability



More information about the LUG mailing list