iis | seo | web-config | rewrite-rule | aspnet

Redirect HTTP to HTTPS using Web.Config in IIS

Use IIS Rewrite rule to redirect all HTTP request to HTTPS.

Abhith Rajan
Abhith RajanSeptember 25, 2017 · 1 min read · Last Updated:

No Stories, just add the below rewrite rule in your Web.Config under system.webServer section so that IIS will take care the redirection of HTTP requests to HTTPS. Since we are about to add a rewrite rule in the IIS,

Before adding the rewrite rule, make sure that you installed the URL Rewrite module in the IIS.

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

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub


Abhith Rajan

Written byAbhith Rajan
Abhith Rajan is a software engineer by day and a full-stack developer by night. He's coding for almost a decade now. He codes 🧑‍💻, write ✍️, learn 📖 and advocate 👍.
Connect

Is this page helpful?

Related ArticlesView All

Related StoriesView All

Related Tools & ServicesView All

metatags.io

Meta Tags — Preview, Edit and Generate

With Meta Tags you can edit and experiment with your content then preview how your webpage will look on Google, Facebook, Twitter and more!
en.ryte.com

Robots.txt generator - Create a robots.txt file instantly

Generate a robots.txt file for free with this easy-to-use tool. Make sure search engine crawlers are crawling and indexing your site.