Windows IIS Server - Reditect http:// to https://

Using the following code in your web.config file automatically redirects visitors to the HTTPS version of your site:

-------------

<configuration>
<system.webServer>
<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>

--------------

If you have an existing
web.config file:

  • Ensure you have sections (i.e. opening and closing tags) for:
    • system.webServer (which contains rewrite)
    • rewrite (which contains rules)
    • rules (which contains one or more rule sections)
  • Insert any of those sections that do not exist.
  • Insert the entire rule section, including match, conditions, and action, inside the rules section.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

URL Rewrite/mod_rewrite for Windows on IIS 7.x 8.x

For customers who are looking for a URL rewrite function (like Apache's mod_rewrite) on our...

Enabling Cache on Your Windows Hosting Account using clientCache

With our Windows hosting accounts, you can create caching rules to enhance your website's speed...

Disabling Browser Cache on Windows Server static files

The following configuration sample adds an HTTP "Cache-Control: no-cache" header to the response,...

Scheduled Tasks (cron job)

Scheduling Tasks (Windows) If you need to run scripts on your hosting account at specific time,...

500 internal server error - How to Get detailed errors

By default, our Windows hosting accounts display a custom/generic error when applications...