Host-it Tutorials WebsiteTutorials

Tutorials

  • Home
  • Categories
    • Client Portal Tutorials
      • Billing Tutorials
      • Support Tutorials
      • Account Settings Tutorials
      • Hosting Packages Tutorials
      • Data Centre Services Tutorials
    • Domains Tutorials
    • Virtual Hosting Tutorials
      • Email Tutorials
      • Databases Tutorials
      • Domains Tutorials
    • PC Software Tutorials
      • FTP / FTPS Tutorials
      • Backup Tutorials
      • Email Tutorials
    • Email Tutorials
    • SellerDeck/Actinic Tutorials
    • Cloud VPS Tutorials
    • Misc Tutorials
    • SSL and PCI Scanning Tutorials
    • Plesk Tutorials
  1. Home
  2. SSL and PCI Scanning

category icon Redirect HTTP to HTTPS

When you install an SSL certificate to enable your site to work with TLS over HTTP (HTTPS) by default this will not automatically redirect all visitors to your your website onto the HTTPS security layer which we would recommend.  Before this redirect can be enabled on your website hosting, your site code should be checked by the sites' developer to ensure that the sites code is ready for https (i.e. no hard links within it going back to http which could force a redirect loop and effectively break the site.)

There are a number of different ways that you can perform the redirect to https on your site and below are 2 examples of how to do this on the Linux and Windows hosting platforms.

Linux

In your webroot create the file .htaccess or if it already exists add to it with the below and save.


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

After saving the file the changes should be imidiate and the site should now be redirecting to https.

Windows

If you are using the Windows IIS hosting platform then you will want to create the redirects in your web.config file.

If you already have a web.config file then you will need to add to it, else create a new file in your webroot and save

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

Once you have added the content and saved the file you should now see the site is redirecting to https.

Tweet Follow @Hostit
For more information or to sign up for any of our hosting services visit the Host-it website.