How to redirect Website from HTTP to HTTPS in windows hosting?

WebSupporters Windows servers support IIS URL Rewrite module. If you have an SSL certificate on your website, you can use this module to automatically redirect your website visitors from HTTP to HTTPS.

How to redirect the Website from HTTP to HTTPS in windows hosting with IIS?

  1. Be sure that the SSL Certificate is properly installed on your domain, and the website is resolving on your domain like https://example.com
  2. Create a web.config file under the site’s directory and add the following lines to it. In case there already exists a web.config in your site’s directory, carefully edit it to add these lines:
    <?xml version="1.0"?>
    <configuration>
      <system.webServer>
         <rewrite>
                   <rules>
                   <rule name="Redirect to HTTPS" stopProcessing="true">
                   <match url="(.*)" />
                        <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                        </conditions>
                   <action type="Redirect" url="https://example.com/{R:1}" redirectType="Permanent" />
                   </rule>
                   </rules>
         </rewrite>
      </system.webServer>
    </configuration>
  3. example.com needs to be replaced by the Domain Name for which the SSL Certificate is issued.

Was this article helpful?

Related Articles