How to Access Your Site only With HTTPS?

How to Access Your Site only With HTTPS?

There are two ways to make it possible to access your site only with HTTPS. Both two ways are based on URL Rewrite. Before starting this, we need to make sure a SSL certificate has already applied for your site and we can access your site with "https://". Usually, we will do this for you and make sure it can work properly. Then let's get a start to set it up.

First method - Coding

The first method is to add the following codes into web.config file. It's very easy, just copy and paste.
<?xml version="1.0" encoding="utf-8"?>
<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>

Second method – Set up in IIS

All customers are allowed to connect to IIS. If you don't know how to connect, please refer to the two tutorials.
After connected to IIS, please locate feature URL Rewrite and double-click on it.
How to Access Your Site only With HTTPS 1
In the new page, there should be an action to add a rule at top-right corner, click on it and select Blank rule to create a new inbound rule.
How to Access Your Site only With HTTPS 2

Part 1 – Name

Please set parameters in Part 1 by referring to the following picture.
How to Access Your Site only With HTTPS 3

Part 2 – Conditions

Please set parameters in Part 2 by referring to the following picture.
How to Access Your Site only With HTTPS 4

Part 3 – Action

Please set parameters in Part 3 by referring to the following picture.
How to Access Your Site only With HTTPS 5
At the end, please don't forget to click Apply button located at top-right corner!
Related Articles