httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Bray" <>
Subject Re: [Httpd Wiki] Update of "Recipes/CanonicalHostNames" by slive
Date Tue, 30 Jan 2007 09:01:22 GMT
Hi Joshua,

On 30/01/07, Apache Wiki <> wrote:
> The comment on the change is:
> The old example would not canonicalize non-listed hostnames.
> ------------------------------------------------------------------------------
>   NameVirtualHost *:80
>   <VirtualHost *:80>
> +   # The first-listed <VirtualHost> is the default host that catches all the
> +   # names specified in its ServerName/ServerAlias, plus all the names
> +   # that are not listed in any other <VirtualHost>, and redirects
> +   # them to the canonical <VirtualHost> below.
> +   ServerName
> +   ServerAlias
> +   Redirect permanent /
> + </VirtualHost>
> +
> + <VirtualHost *:80>
>     # Canonical host
>     ServerName
>     DocumentRoot /usr/local/apache/htdocs
>   </VirtualHost>
> - <VirtualHost *:80>
> -   # Non-canonical names for the above vhost
> -   ServerName
> -   ServerAlias
> -   Redirect permanent /
> - </VirtualHost>
>   }}}
>   == Using mod_rewrite ==

The change I made was a result of a user in #apache getting confused
about the default vhost part. He already had a default vhost (debian
config) and didn't want to edit it to redirect non-canonical hostnames
for a single vhost. This makes sense when you apply this config
pattern to multiple hostname combinations. Here's the conversation, up
to you if you want to remove the default vhost comment.

*	Luke ( has joined #apache
<Luke>	i'm trying to find a rewrite rule that will forward from to what would I call that so I can more
effectively search?
<noodl>	Luke: you don't need mod_rewrite for that, just Redirect in a
separate vhost. for a search, i'd suggest 'canonical hostname'
<Luke>	i'm not sure how to do that. searching canonical hostname is
actually how I found how to do mod_rewrite
<noodl>	Luke:
<Luke>	i found how to remove www (i had to use quotes)
<Luke>	why is it not good to use mod_rewrite in this case?
<noodl>	granny
<fajita>	Granny Weatherwax tells us the most important thing about
magic is when _not_ to use it.  The same is true of mod_rewrite.
<noodl>	it's just slower and unnecessary
<Luke>	much easier though
<noodl>	really? i don't think so.
<noodl>	RedirectPermanent is pretty straight-forward imho.
<Luke>	i dont just have one vhost though
<noodl>	only you need rewrite for this is when you cant edit the main
config and need to use .htaccess
<Luke>	yea
<noodl>	doesn't make any difference. just add another vhost.
<noodl>	(that wiki page is misleading talking about the first one
being the default, it's kinda irrelevant to the example)
<Luke>	looks here like it goes in the default vhost
<Luke>	ah
<Luke>	thats what was confusing me
<Luke>	so I just make a vhost for the www and use redirect?
<noodl>	yep
<noodl>	fixed the page
<Luke>	cool thaks
<Luke>	thats much better now


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message