How to Redirect HTTP to HTTPS in IIS

Introduction

If your website has an SSL certificate installed, it’s highly recommended to make sure all visitors are automatically redirected from HTTP to HTTPS. This ensures that communication between your website and visitors is encrypted and secure.

In this tutorial, we’ll show you step-by-step how to redirect HTTP to HTTPS in IIS using the URL Rewrite module. Even if you’re a beginner, you’ll be able to set up an IIS HTTPS redirect easily by editing the web.config file.

Why Redirect HTTP to HTTPS?

  • Security: HTTPS encrypts all traffic and protects sensitive data.
  • SEO Benefits: Google prefers HTTPS websites in search rankings.
  • Trust: Visitors feel safer when they see the padlock in the browser.

If you are hosting your site on a Windows Server with IIS, this guide will show you how to set up IIS rewrite HTTP to HTTPS quickly.

Steps to Redirect HTTP to HTTPS

Step 1: Open Your Web.config File

  1. Connect to your web server using FTP or your hosting control panel’s File Manager.
  2. Locate your website’s root directory.
  3. Open the web.config file using a text editor.

Step 2: Add IIS Rewrite HTTP to HTTPS Rule

Now, insert the following rule into your web.config file inside the <configuration> section.

Option 1: Basic HTTPS Redirect

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

Option 2: HTTPS Redirect with Exclusion for Localhost

If you don’t want to apply HTTPS redirection for localhost testing, use this version:

<system.webServer>
  <rewrite>
    <rules>
      <rule name="http redirect to https" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
          <add input="{HTTPS}" pattern="^OFF$" />
          <add input="{HTTPS_HOST}" pattern="^(localhost)" negate="true" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

Step 3: Save and Upload the Web.config File

  1. Save the changes in your editor.
  2. Upload the updated web.config file back to your web server using FTP or File Manager.

Once uploaded, the IIS HTTPS redirect rule takes effect immediately. Visitors accessing your website with http:// will be forwarded to https:// automatically.

Step 4: Verify the HTTPS Redirect

  • Open your browser and type your website URL with http://.
  • It should automatically redirect to https://.

Congratulations! You’ve successfully configured IIS redirect HTTP to HTTPS using URL Rewrite.

Notes

Conclusion

Redirecting HTTP to HTTPS in IIS is an essential step for securing your website. By adding a simple IIS URL Rewrite HTTP to HTTPS rule in the web.config file, you can enforce HTTPS and protect your visitors.

This method works perfectly for:

  • iis forward http to https
  • iis ssl redirect
  • iis http redirect to https
  • how to redirect http to https in iis

With this setup, your site will not only be more secure but also more trusted by users and search engines.

Keywords:

forward http to https iis, https redirect iis, iis forward http to https, iis redirect https, iis ssl redirect, redirect iis http to https, redirect http to https iis, iis https redirect, iis rewrite http to https, iis url rewrite http to https, iis http to https, iis http redirect to https, how to redirect http to https in iis, http to https iis, http redirect to https iis

Outline