0
<rule name="UreRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
    <add input="{HTTPS}" pattern="^OFF$" />
    <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" redirectType="SeeOther" />

I am using above web.config code that

I have all possible bindings added with IIS

SSL is configured for example.com but not with www.example.com

I tried these links but these are irrelevant

iis url redirect http to non www https

How to redirect http to https and www to non-www via web.config?

Farukh Zahoor
  • 157
  • 12

1 Answers1

0

You can use this:

<rewrite>
  <rules>
    <rule name="redirect" enabled="true">
      <match url="(.*)" />
      <action type="Redirect" url="https://piposx.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>
  • It looks redirection works after we click proceed to unsafe website. May be I will have to add www.piposx.com to secure website with my hosting? – Farukh Zahoor Feb 14 '18 at 12:36
  • I already wrote www.piposx.com and its working. You might need to clear your browser cache. – Octavio Durana Feb 14 '18 at 12:42
  • have you tried https://www.piposx.com ? – Farukh Zahoor Feb 14 '18 at 14:13
  • Ok, I see. I think the problem is that you have configured a SSL Certificate for https://www.piposx.com (https:// www . piposx .com), if you open the certificate details it says that it has been issued to crititac.com. Remove this from your configuration and all should work fine. – Octavio Durana Feb 16 '18 at 00:00
  • Can you please explain? – Farukh Zahoor Feb 16 '18 at 09:37
  • When you try to enter the www domain over https, it points that it has a certificate configured to the domain crititac.com, you can check this by clicking the SSL padlock next to the address bar on your browser, GoDaddy issued this certificate, but it's invalid since you have configured an SSL that doesn't correspond to your domain, removing this from your configuration should correct the problem. To clarify, you have two SSL configured on your domain, one with www and one without www, you have to remove the first one since it is pointing to another domain. – Octavio Durana Feb 16 '18 at 18:10
  • The error is this: This server could not prove that it is www.piposx.com; its security certificate is from crititac.com. This may be caused by a misconfiguration or an attacker intercepting your connection. – Octavio Durana Feb 16 '18 at 18:19