Automatically Redirecting Visitors to HTTPS on Your Windows Hosting Account
If you have an SSL on your Windows® hosting account, you can make sure your visitors always have a secure connection by automatically directing HTTP connections to HTTPS.
To do this, you'll need to either create or modify your hosting account's web.config
file. If you need to create one, see:
- Creating New Files and Folders Using the File Manager — Name the file you create web.config.
- Use the example from How To Create the Web.config File for an ASP.NET Application.
In the web.config
file you create, you also need to add <rewrite>
and <rules>
tags, as well as close them (</rewrite>
and </rules>
), in the <system.web>
section.
To Automatically Redirect Visitors to HTTPS
- Using your hosting account's editor, open your account's
web.config
file. - In the
<rules>
section, add the following code:<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> - Save your changes.