httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua Slive" <>
Subject Re: [users@httpd] Rewrite problem (adding www.)
Date Thu, 09 Nov 2006 14:46:05 GMT
On 11/8/06, Geoff Soper <> wrote:
> Hi,
> I use the following piece of code in an .htaccess file at
> /var/www/vhosts/ to get traffic from
> onto which works perfectly:
> RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
> RewriteRule ^(.*)$$1 [R=301,L,NE]
> However when the root of the site in question isn't at the top level of
> the domain (the following in an .htaccess file at
> /var/www/vhosts/
> RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
> RewriteRule ^(.*)$$1 [R=301,L,NE]
> it fails in a certain case which leads to a request for
> (note no trailing bracket) being served
> instead of or
> Can someone suggest how I make the rewrite condition / rule more robust?

Use the RewriteBase directive or use %{Request_URI} explicitly in the
rewriterule.  (Or, even better, if you have access to httpd.conf, put
the RewriteRules in there.)


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