Windows > General Windows

Redirect HTTP to HTTPS in IIS 7.5

(1/1)

linsonj:

Redirecting all traffic from HTTP to HTTPS in IIS7.5 will make sure your users always access the site securely.

In the following example we will redirect HTTP to HTTPS using URL Rewrite.

You will need the following items completed in order for this to work correctly.

- SSL Certificate for site installed in IIS.
- Site properly installed and configured for SSL (site set up and binding in IIS configured).
- URL Rewrite 2.0 is installed on the sever.

All this does is edit the web.config file of the site.

Open the web.config file of the site and copy-paste the below code in it

===========

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="Index.php" />
                <add value="Index.html" />
                <add value="Index.htm" />
                <add value="Index.cfm" />
                <add value="Index.shtml" />
                <add value="Index.shtm" />
                <add value="Index.stm" />
                <add value="Index.php3" />
                <add value="Index.asp" />
                <add value="Index.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="Default.aspx" />
            </files>
        </defaultDocument>
<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>


================

Test the site by going to http://www.yoursite.com and making sure it redirects.

Navigation

[0] Message Index

Go to full version