Redirect HTTP to HTTPS

Programming, error messages and sample code > sample code
Redirecting all traffic from HTTP to HTTPS in IIS will make sure your users always access the site securely.

What you need to do to set the redirection from HTTP to HTTPS is adding the corresponding URL rewrite rule to your web.config file.
Method 1: do it from your Control Panel

Method 2:  put the following code into the web.config file in the root folder of your website.
<?xml version="1.0" encoding="UTF-8"?>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
            <match url="(.*)" />
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
And now test the site by going to and making sure it redirects.