Forum Moderators: open
[ISAPI_Rewrite]
RewriteCond Host: mydomain\.com
RewriteRule /(.*) [mydomain.com...] [RP,L]
I am having canonical URL issues with Google so I want non-www urls to be 301ed to WWW urls like this:
mydomain.com/page1.htm
I would like that redirected to
www.mydomain.com/page1.htm
Will this rewrite rule do this properly? Is it seen as a 301 basically?
RewriteCond Host: mydomain\.com
RewriteRule /(.*) http://www.mydomain.com/$1 [RP,L] What I have as a working example...
RewriteCond Host: ^example\.com
RewriteRule (.*) http\://www\.example\.com$1 [I,RP] There appear to be some slight differences between theirs and what I've been using for years. I can't specify whether or not theirs is correct or incorrect. I do know that the code I provided is doing exactly what you specify.
In Apache mod_rewrite, the only characters than need be escaped in the substitution URL are the "back-reference and variable indicators" - "%" and "$". If the same is true for ISAPI Rewrite, then the two code snippets are essentially identical except for the handling of the leading slash, which is equivalent.
Jim
[edit] Speling [/edit]
[edited by: jdMorgan at 6:24 pm (utc) on Jan. 8, 2007]