To redirect your website from HTTP to HTTPS automatically, you need to place the following code using an  .htaccess or web.config file. 

Linux  – Force HTTPS using .htaccess

You should use the following code within the  .htaccess file for your website.  This file should be placed within the root of your website.  This is normally the same location as your websites index page.  This code forces users to redirect to an HTTPS connection.

RewriteEngine on
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.domainname.com%{REQUEST_URI} [L,R=301]


Windows  – Force HTTPS using web.config

You should use the following code within the web.config  file.  This file should be placed within the root of your website files.  This is normally the same location as your websites index page.   This code forces users to redirect to an HTTPS connection.

<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>

If you have any questions please contact us

  • .htaccess, web.config, ssl redirect
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

Managing Website Scripting

From your account control panel select "Websites". then the website in question. then...

Adding or Removing a Domain Alias / Pointer

In order to add an alias (sometimes called a pointer) to a domain, select "Websites" from the...

How do I update my password?

You can update the password within your Cloud Control panel by selecting the user icon in the...

Should I put my website on a Windows server or Linux server?

The general rule of thumb when deploying your website is to use the server type that is native to...

How do I add a MySQL or MS SQL database?

From your control panel, click on the Databases option on the left side of the screen Click...