httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Slive <>
Subject Re: [users@httpd] Domain redirect with browser location change
Date Fri, 18 Jun 2004 18:05:23 GMT

On Fri, 18 Jun 2004 wrote:
> Hmmm... alright.  I guess my main point of confusion about this is, will
> that definitely change the browser location?

Yes.  That is the one and only point of this example.

> Also, is there any way to
> modify this so that any domain other than [www.] is
> redirected?

The first-listed virtual host will catch any requests that don't match any 
listed ServerName/ServerAlias.  Hence by doing the Redirect in the first 
<VirtualHost> block (as in the example), all unknown names will also be 

> I
> suppose we could detail every domain name we expect, but can we add a
> catchall VirtualHost, such that links to
> pass striaght through to that exact
> address, but a link to that machine using any other domain gets redirected
> to the home page (i.e. even if it's

Now you are asking for three different behaviors, so you'll need three 
<VirtualHost> sections, as follows:

> NameVirtualHost *

<VirtualHost *>
# Catch any unlisted names and redirect to the homepage.
# (RedirectMatch does not automatically tag on the path
# to the target like Redirect does.)
# Note that the ServerName is irrelevant, but must be
# set to something.
ServerName catch-all 
RedirectMatch permanent .*

> <VirtualHost *>
>   ServerName
>   ServerAlias
>   Redirect permanent /
> </VirtualHost>
> <VirtualHost *>
>   ServerName
>   ServerAlias
>   DocumentRoot /path/to/www/root
> </VirtualHost>
> Is that right?


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

View raw message