0
votes

I recently moved my website from http to https My SSL certificate is for www.domain.com and not for domain.com, i.e. with www as prefix.

Now I facing an issue, when someone is accessing my website as http://www.domain.com it redirect to htts://www.domain.com without any issue as I have mentioned permanent redirect in web.config rewrite rules using following rules

<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
<match url="(.*)" /> 
<conditions logicalGrouping="MatchAll">
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/mobile.asmx*" ignoreCase="true" />
</conditions> 
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>   
  </rules>
</rewrite>

However, when some is trying http://domain.com I am getting certificate error as SSL certificate is for domain with www prefix.

What I need help with is that rewrite should work as follows: if request is from http://www.domain.com then move it to https://www.domain.com however, if request is from http://domain.com then also move it to https://www.domain.com.

Please help if possible as the issue is with live website.

1

1 Answers

0
votes

I got it, all I need is to add www.

<action type="Redirect" redirectType="Permanent" url="https://www.{HTTP_HOST}/{R:1}" />