Windows > General Windows

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

(1/1)

sibij:
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: ---<?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>

--- End code ---

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


Navigation

[0] Message Index

Go to full version