If you have a SSL certificate on your website and you need all the HTTP visitors to be automatically redirected to the secured (HTTPS) version of the website to make sure the communications are encrypted, here is the how-to for this purpose.
Our shared web hosting are using Windows Server systems with IIS. After the SSL certificate is installed on your website, you may add URL rewrite rule in the web.config file for automatic https redirection.
1. Using your text editor, open the web.config file.
2.The URL rewrite rule for https redirection to be added is as the following,
<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>
Edition2
<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>
3. Simply copy the rule to your web.config file. Save the change.
4. Upload the saved web.config file to the web server that hosts your website through FTP or via File Manager of your control panel account.
5. The new rule takes effect immediately when the file is uploaded.
Notes:
Article ID: 67, Created: June 19, 2015 at 9:48 AM, Modified: February 17, 2021 at 9:24 PM