Redirect HTTP to HTTPS using Web.Config in IIS

Add the below rewrite rule in your Web.Config under system.webServer section,

<rewrite>
      <rules>
        <rule name="httpsredirect" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="https://yourdomain.com/{R:1}" />
        </rule>
      </rules>
    </rewrite>

Replace the yourdomain.com with the actual domain name and you are good to go. If this isn't working, make sure that you installed the URL Rewrite module in the IIS.


comments powered by Disqus

About the author

  • Abhith Rajan

    Abhith Rajan

    Abhith Rajan is a full-stack developer, consultant, Sysberries employee, and biker. Who passionate about C# and JavaScript. Works on his blog, his personal finance web app and its react native mobile app in his free time.

    Buy me a coffeeBuy me a coffee