How Do I Redirect HTTP to HTTPS Automatically?

Redirect http To https Automatically:

To redirect http to https automatically just add below mentioned code in web.configuration file under <configuration>:

<system.webServer>

    <rewrite>

      <rules>

<rule name="HTTP to HTTPS redirect" stopProcessing="true">

  <match url="(.*)" />

    <conditions>

      <add input="{HTTPS}" pattern="off" ignoreCase="true" />

    </conditions>

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

</rule>

</rules>

    </rewrite>

  </system.webServer>

Just save the web.config file and your domain is all set to redirect to https automatically.

Was this answer helpful? 17 Users Found This Useful (45 Votes)