What kind of 'loop' -- an external redirection loop (multiple browser HTTP redirects and requests), or an internal rewriting loop? Is there anything in your server error log? Is UseCanonicalName set to "on" with the "www" hostname declared as the (incorrect) canonical ServerName? Are there any other RewriteRules or mod_alias directives which may be interfering? BTW, don't end-anchor the pattern used to check the hostname. Or if you do feel you need to end-anchor it, then follow the ".com" with \.?(:[0-9]+)?$ so that FQDNs and hostnames with appended port numbers won't defeat the rule. Also, escape all literal periods in regex patterns by preceding them with "\":
RewriteCond %{HTTP_HOST} ^www\.example\.com\.?(:[0-9]+)?$ [NC] An alternative, if you don't plan to use subdomains in additional to "www", would be to redirect anything that is *not* exactly the canonical hostname:
RewriteCond %{HTTP_HOST} !^example\.com$ (Note negated pattern, no FQDN or port allowed, no uppercase allowed -- all would get redirected to all-lowercase "example.com") Jim
|