Home How toASP.NET Force all traffic from HTTP to HTTPS using Web.Config file

Force all traffic from HTTP to HTTPS using Web.Config file

by Wikky
1 comment
force-http-to-https
force-http-to-https
force-http-to-https

Once you have setup your SSL the next thing is to redirect all traffic of your website from HTTP to HTTPS. By default your website is accessible from HTTP. And you can configure it by many ways at IIS, Application coding level or WEB.CONFIG file. The simplest way to do it at WEB.CONFIG level.

Open Asp.Net WEB.CONFIG file and Put following rewrite rule tags under the <system.webServer> tag.

<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>

Save and publish it on server. Now check your website will start loading at HTTPS.

Hope this works!


You may also like

1 comment

Esteban July 1, 2021 - 7:04 am

Hello are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get
started and create my own. Do you need any html coding expertise
to make your own blog? Any help would be really appreciated!

Reply

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More