Redirect to HTTPS in web.config

If you have an SSL certificate installed and working already, you can force HTTPS on your website by simply adding the following code into your web.config.

Before doing so, it's highly recommended that you make a backup of the web.config file before making any changes. Also, you can't simply copy/paste the code anywhere in the web.config. You'll need to select just the <rewrite> section below from start to finish and place it strategically in the web.config. Any issues with this, please contact support and we'll be glad to assist.

<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="Permanent" url="https://{HTTP_HOST}/{R:1}" />
       </rule> 
    </rules>
</rewrite>
</system.webServer>
</configuration>

Any traffic coming to the HTTP version of your website will automatically be redirected to HTTPS.

Please see our other knowledgebase articles regarding the same topic below:

 


Looking for reliable Windows hosting with Award Winning Customer Support?
Grab your hosting today with a 20% discount. All plans come with our 60 Money Back Guarantee!

Check out our plans & promotions on our website -- https://www.peopleshost.com/

  • SSL, redirect to ssl, ssl certificate
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Do I need a SSL certificate?

Do I really need an SSL certificate? Historically,  your website would only need an SSL...

Common types of SSL certificates

While there are many different types of SSL certificates, we'll cover the main three PAID...

Shared SSL Certificates

Unfortunately, we do not offer any shared SSL certificates on either or Linux or Windows shared...

How to buy an SSL certificate

You can purchase an SSL certificate automatically via your secure billing portal here --...

Self Signed SSL Certificate

If you are a developer, webmaster or site owner and you need to test SSL functionality on your...