Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to redirect Website from HTTP to HTTPS in windows hosting with IIS?  (Read 8063 times)

0 Members and 1 Guest are viewing this topic.

sibij

  • Guest
How to redirect Website from HTTP to HTTPS in windows hosting with IIS?  ::)


Be sure that the SSL Certificate is properly installed on your domain, and the website is resolving on your domain like https://example.com
    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:
Code: [Select]
<?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>

    example.com needs to be replaced by the Domain Name for which the SSL Certificate is issued. 8)