How to Redirect HTTP to HTTPS with Windows IIS 10

To create redirection rules in IIS, you must download and install the URL Rewrite Module 2.1 IIS module (https://www.iis.net/downloads/microsoft/url-rewrite).

Then open the Internet Information Services Manager console (InetMgr.exe) and select your site.

Go to the SSL Settings section and make sure that the Require SSL option is not enabled. If not, this will cause a conflict with the Rewrite URL redirect rule resulting in 403.4 forbidden errors.

Do not enable SSL on IIS

Then go to the URL Rewrite section.

Install URL rewrite module on IIS on Windows

Select Add Rule -> Blank rule.

Specify the rule name and configure the following parameter values:

  • Requested URL -> Matches the Pattern
  • Using -> Wildcards
  • Pattern -> *
Create rewrite rule to redirect from HTTP to HTTPS

In Conditions, change Logical Grouping to Match All and click Add. Configure the options:

  • Condition input -> {HTTPS}
  • Check if input string -> Matches the Pattern
  • Pattern -> OFF
  • Ignore case: enabled
HTTPS redirect rule on IIS

Now move on to the Action section and set:

  • Action Type -> Redirect
  • Redirect URL -> https://{HTTP_HOST}{REQUEST_URI}
  • Redirect type -> Permanent (301)
Create permanent redirect (301) to HTTPS on IIS

Once the redirect rule is created, you will need to reset IIS with the following command:

iisreset

iisreset

Open your browser and try to access your website using the HTTP address. You should be automatically redirected to the HTTPS URL.

check HTTP to HTTPS redirect

You can also manually enable the HTTP-to-HTTPS redirection IIS rule in the web.config file:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="rewrite_rule_Redirect_HTTP_to_HTTPS" patternSyntax="Wildcard" stopProcessing="true">
           <match url="*" />
              <conditions>
                <add input="{HTTPS}" pattern="OFF" />
             </conditions>
           <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

This HTTP to HTTPS redirect rule in IIS will work on the current versions of Windows Server 2022, 2019, 2016, and Windows 10/11.

Ref: Redirect HTTP to HTTPS with Windows IIS 10 – SSL.com