Rewrite https://domain.com to https://www.domain.com

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 7
Joined: 17 Dec 2012, 11:23
Location: Pennsylvania

Rewrite https://domain.com to https://www.domain.com

12 Sep 2016, 12:33

I have the following site specific rule

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC, OR]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC, OR]
RewriteRule ^/(.*) https://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC, OR]
RewriteRule ^/(.*) https://www.domain.com/$1 [R=301,L]

1) The purpose of this rewrite is to push all traffic to SSL with a www prefix
2) (working) [http://www.domain.com/test-v23.htm?test=123] -> redirects correctly
3) (working) [http://domain.com/test-v23.htm?test=123] -> redirects correctly
4) (working) [https://www.domain.com/test-v23.htm?test=123] -> redirects correctly
5) (error) [https://domain.com/test-v23.htm?test=123]

the second rule doesn't appear to trigger. x`

I've tried multiple ways but I can not get https://domain.com to rewrite to https://www.domain.com

Your help is always appreciated. A helicon customer for over 10 years...

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Rewrite https://domain.com to https://www.domain.com

20 Sep 2016, 07:46

Hello.

HTTPS should be NC as with some IIS versions it is 'on' and with others it is 'On'.
Please try:

RewriteCond %{HTTPS} off [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.com$ [NC]
RewriteRule (.*) https\://www.domain.com$1 [R=301]

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*) https\://www.domain.com$1 [R=301]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 13 guests