httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geoff Millikan" <>
Subject RE: [users@httpd] Special configuration for requests that do not match any particular virtual host? Apache 2.2
Date Thu, 02 Jun 2011 00:40:50 GMT
> Actually on second thought, the rewrite rule in the first host 
> should be like this to avoid loop:
>      RewriteEngine On
>      RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [OR]
>      RewriteCond %{HTTP_HOST} !^mydomain\.com
>      RewriteRule     .*{REQUEST_URI} [L,R=301]

Per manual excerpted below, the first <VirtualHost> section should only be used when
the hostname being requested isn't listed
anywhere else in a ServerName or ServerAlias, right?!  So these RewriteCond shouldn't be needed!

I'd use exclusion RewriteCond but since we have other domain names on the server like
and etc we'd have to write rule for each domain.  Messy. 



"Now when a request arrives, the server will first check if it is using an IP address that
matches the NameVirtualHost. If it is,
then it will look at each <VirtualHost> section with a matching IP address and try to
find one where the ServerName or ServerAlias
matches the requested hostname. If it finds one, then it uses the configuration for that server.
If no matching virtual host is
found, then the first listed virtual host that matches the IP address will be used."

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