Redirect website from http to https

Posted by MaG3Stican on Stack Overflow See other posts from Stack Overflow or by MaG3Stican
Published on 2013-07-01T16:58:51Z Indexed on 2013/07/01 17:06 UTC
Read the original article Hit count: 362

Filed under:
|
|

I have a website stored on azure for which I got an SSL certificate. I am trying to redirect www.mywebsite.com to https://www.mywebsite.com but with no success.

I am using the following code that should change the configuration of IIS where my project is deployed :

<system.webServer>
<rewrite>
  <rules>
    <rule name="Redirect to HTTPS">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        <add input="{URL}" pattern="/$" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
    </rule>
  </rules>
</rewrite>

But when I type my URL it does not redirect to https.

By the way, rewrite appears unrecorgnized by Intellisense.

© Stack Overflow or respective owner

Related posts about c#

Related posts about iis