Thursday, April 5, 2012

URL Rewrite for SSL redirection

 

Automatically Redirect HTTP requests to HTTPS on IIS 7 using URL Rewrite 2.0

If you want users to be automatically redirected to an HTTPS site;

· Install Microsoft URL Rewrite Module, downloadable from: http://www.iis.net/download/URLRewrite

· Be sure a SSL certificaat is installed and bind it too your web site

· Disable : Require SSL clip_image001

· Copy and paste the following code: between <rules> and </rules> tags in the web.config file in the website root directory.

C:\inetpub\wwwroot\wss\VirtualDirectories\....

Edit the web.config file

<rule name="Force HTTPS" enabled="true">
        <match url="(.*)" ignoreCase="false" />
        <conditions>
            <add input="{HTTPS}" pattern="off" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>

Wanneer je dit hebt gedaan, zorg er dan voor dat je de website ook gebind hebt op poort 80:

clip_image002

When opening the http site now, you will be automatically redirected to the HTTPS site:

<rewrite>

<rules>

<rule name="Force HTTPS" enabled="true">

<match url="(.*)" ignoreCase="false" />

<conditions>

<add input="{HTTPS}" pattern="off" />

</conditions>

<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />

</rule>

</rules>

</rewrite>

No comments:

Post a Comment