In order to redirect HTTP requests to HTTPS in IIS, you can use the URL Rewrite or HTTP Redirect module.

In the screenshot below you can see both modules in the IIS Manager.


HTTP Redirect module vs URL Rewrite module with Action type: Redirect

Technically there is no difference to the HTTP Redirect module when using the URL Rewrite module with an action type from Redirect.

Both will result in a client-side request, so the browser will be forced to send another second request to the new URL.

But using the URL Rewrite module with an action type from Redirect will give you more options to create complex rules for redirecting.


Regarding the differences between an URL Redirect vs. Rewrite, you can read the following great post from Scott Forsyth.

URL Rewrite vs. Redirect; What’s the difference?
https://weblogs.asp.net/owscott/rewrite-vs-redirect-what-s-the-difference
https://blogs.iis.net/owscott/url-rewrite-vs-redirect-what-s-the-difference


The HTTP Redirect module can be installed as a feature within the Web Server (IIS) server role using the server manager.

The URL Rewrite module in contrast can be installed with the Web Platform Installer in IIS or you can download and install the module directly from the following link.

URL Rewrite extension
https://www.iis.net/downloads/microsoft/url-rewrite

After the installation we will see the new module within the IIS section in the IIS Manager as follows after closing and reopening the IIS Manager.


To create a new redirect rule we click on the URL Rewrite module.

Here from the Actions panel we click on Add Rule(s)…

Here we need to click on Blank rule in the Inbound rules section.

Now in the Edit Inbound Rule form we need to configure the following parameters.

  • Name: Redirect to https
  • Requested URL: Matches the Pattern
  • Using: Regular Expressions
  • Pattern: (.*)
  • Ignore case checkbox: checked

For the conditions section we need to configure the following parameters.

Leave Match All in the Logical grouping drop down list and click on the Add ... button.

  • Condition input: {HTTPS}
  • Check if input string: Matches the Pattern
  • Pattern: ^OFF$
  • Ignore case: checked


For the action section we need to configure the following parameters.

First select the action type Redirect in the drop down list

  • Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
  • Append query string: unchecked
  • Redirect type: Permanent(301)

Redirection messages
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages

You will find here all 3.. redirection messages.


Now we can click on Apply in the Actions panel to save the new rule.


This rule normally will be written into your web.config file from your web application you configured for.







Links

Download URL Rewrite
https://www.iis.net/downloads/microsoft/url-rewrite

Web Platform Installer
https://www.microsoft.com/web/downloads/platform.aspx

Web.config redirects with rewrite rules – https, www, and more
https://blog.elmah.io/web-config-redirects-with-rewrite-rules-https-www-and-more/

URL Rewrite vs. Redirect; What’s the difference?
https://weblogs.asp.net/owscott/rewrite-vs-redirect-what-s-the-difference