Redirecting all traffic from HTTP to HTTPS in IIS will make sure your users always access the site securely.
What you need to do to set the redirection from HTTP to HTTPS is adding the corresponding URL rewrite rule to your web.config file.
Method 1: do it from your Control Panel
Method 2: put the following code into the web.config file in the root folder of your website.
<?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="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
And now test the site by going to http://www.yoursite.com and making sure it redirects.
Article ID: 345, Created: March 1, 2013 at 12:40 AM, Modified: December 23, 2020 at 7:55 PM