Redirect non-SSL to SSL in Windows (IIS) Print

  • 0

The following code sample will 301-redirect http://www.domainname.com to https://www.domainname.com with the following requirements:

1. IIS v7 (Windows 2008) or newer

2. The site's application pool runs in "integrated" mode

3. The URL Rewrite module is installed

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTPS}" pattern="off" ignoreCase="false" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{URL}" redirectType="Permanent" />
                </rule> </rules> </rewrite> </system.webServer> </configuration>

Was this answer helpful?

« Back