Aw, Stevie, you KNOW better than this!
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
SHOULD BE:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]
The use of example.com needs to have the dot character escaped (to specify the dot character rather than a metacharacter representing ANY character) and, because {HTTP_HOST} is not case sensitive, it requires the use of the No Case flag.
As for creating a new variable when you already have the {REQUEST_URI} available, IMHO, that's a waste of CPU resources. Best to just get to the redirection with the {REQUEST_URI} (which also sorts out the question of Apache 1.x or 2.x with the leading /).
Regards,
DK
Bookmarks