Forcing your site to use SSL (https://) using cPanel

Firstly, you will need to have installed an SSL certificate for your site – A guide on how to do this can be found <here>

Once you have installed your certificate you will need to redirect your site from http:// to https://

There are a few ways that this can be done.

Forcing via the .htaccess file

To force all web traffic to HTTPS insert the following code in the .htaccess file in your website’s root folder.

Important:If you have any existing code in your .htaccess, add this above where there are already rules with a similar starting prefix.

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

Be sure to replace www.mysite.com with your actual domain name. To force a specific domain to use HTTPS, use the following lines of code in the .htaccess file in your website’s root folder:

RewriteEngine On RewriteCond %{HTTP_HOST} ^mysite.com [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

Make sure to replace mysite.com with the domain name you’re trying force to https. Additionally, you need to replace www.mysite.com with your actual domain name. If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that specific folder:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} folder RewriteRule ^(.*)$ https://www.mysite.com/folder/$1 [R,L]

Make sure you change the folder reference to the actual folder name. Then be sure to replace www.mysite.com/folder with your actual domain name and folder you want to force the SSL on.

Forcing https:// with a WordPress plugin

There are lots of plugins available for this purpose, however, the we recommend ‘Really Simple SSL’ – this can be downloaded in WordPress via the Plugins section of your Dashboard or from the wordpress.org plugin repository. One thing you will need to do when setting https:// for your WordPress site is ensure your ‘Site URL’ in Settings -> General also uses ‘https://’.

Leave a Reply

Your email address will not be published. Required fields are marked *

Need Help On A Project?

Contact us today with your query and we’ll see if we can help you get the gears rolling.