0

I am trying to redirect calls to http://mydomain.com to http://www.mydomain.com. Is there a simple way to do it in IsapiRewrite file?

I have tried the following but it is not working:

RedirectRule ^mydomain.com$ www.mydomain.com [R=301]

Also tried this:

RewriteCond %{HTTP_HOST} ^mydomain.com [I]

RewriteRule (.*) http\://www.mydomain.com$1 [I,RP]

Any idea what I am doing wrong.

Thanks!

user1810724
  • 83
  • 1
  • 1
  • 4

1 Answers1

0

Here's the code:

RewriteEngine on

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
Andrew
  • 511
  • 3
  • 7
  • this doesn't work. Any other suggestions? One error I got in the log file was R cannot be used with RewriteRule, use RedirectRule instead. So I tried without R=301 as well as RedirectRule. Neither worked. – user1810724 Jul 11 '13 at 00:37
  • What product is it? I assumed it's ISAPI_Rewrite 3. If it's 2 then try RP instead of R=301 – Andrew Jul 11 '13 at 04:05
  • This worked for me: RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [I] RedirectRule (.*) http://www.%1%2 [R=301] – user1810724 Jul 11 '13 at 19:09