httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Boyle <>
Subject Re: Named Based Virtual servers
Date Thu, 13 Dec 2001 08:52:30 GMT
Matthew Daubenspeck wrote:
> I am using a bunch of name based virtual servers with Apache and Debain.
> All of my domains are in the format of:
> with a DNS CNAME of pointing to
> I am using named virtual servers for the's and it works great.
> However, if any of the plain old address is used, the first server
> in httpd.conf is served.
> Do I have to add an entry for all of the named possibilities, or is there a
> way to reject any other names except for the ones listed in httpd.conf.

We have a similar situation in that we have a lot of legacy FQDNs in DNS
which should point to our canonical ".com" address. 

One way to do it would be as Runeimp suggests with "ServerAlias" but we
have dozens of old addresses. So, like Billy Harvey, we take advantage
of the fact that when apache receives a "Host:" header and if NBVH is
set up, it searches through the VHs looking for a ServerName match. If
it doesn't find one, it uses the first one.

So we do (as our very first VH):

  ServerName any
  RedirectMatch permanent (.*)$1

This way, if we get an old address coming in, apache searches the VHs
for the servername, doesn't find it, so goes to the first one, ignores
the ServerName, and so redirects the client to our canonical name. The
redirect has the effect of changing the URL in the client's browser so,
hopefully, educating him that our URL has been updated.

Note that the ServerName argument "any" is not important (since it gets
ignored on the second pass)- we could put "frumious.bandersnatch" there
and it would still work.


Owen Boyle.

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message