Force SSL/HTTPS connection (cPanel)

If you wish to use HTTPS instead of HTTP for your site, you will need to ensure a SSL certificate is installed in the control panel.

If you do not have a SSL certificate installed, you can consider to either purchase a SSL from APC or wait for 24 hours where our system will install the Let’s Encrypt free SSL for you.

There are 2 ways to direct your visitor to the HTTPS version of your site.


The 1st method would be to toggle the switch for "Force HTTPS Redirect" under the "Domains" page in the cPanel control panel. 

Once you have toggled it, the settings will be saved automatically. 

Kindly wait for about 5 minutes for the effect to take place.


The 2nd method is that you will need to add the following code in the respective .htaccess file.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

If you are not sure on how to add the above code to your .htaccess file, kindly follow the steps below:

-    Visit the site you intend to add the code to ensure the site is currently working with no issue.
- Login to your control panel.
-    Click on “File Manager”.

-    Click on “Settings” on the right side of the page and tick the checkbox for “Show Hidden Files (dotfiles)” and click on “OK”.

-    If the force of HTTP to HTTPS is for your main domain (eg. Domain.com), navigate to “public_html” folders. Locate the “.htaccess” file. Right click on the file and select “Download” to download the current working .htaccess  to your local machine. When prompt, select a destination where you can locate the file in the event you need to retrieve the original code and save it.

-    If the force of HTTP to HTTPS is for your subdomain (eg. Alpha.domain.com), navigate to “public_html” and follow by subdomain directory (which in this example it is called “alpha”). Locate the “.htaccess” file. Right click on the file and select “Download” to download the current working .htaccess to your local machine. When prompt, select a destination where you can locate the file in the event you need to retrieve the original code and save it.

-    Once the backup .htaccess file is downloaded to your local machine, right click on the “.htaccess” file in the file manager and select “Code Edit”.

-    When prompted, select “Edit”.

ForceSSLcPanel5.png

-    If your .htaccess has an existing code, you will may need to check with your developer if there is any issue if the code is replaced. If there is no issue, you will need to replace the section under “RewriteEngine On” with the above mentioned code. Please note you may not be seeing the same the code from the screenshot in your .htaccess as they are written differently.

-    Kindly use another browser and visit the site. If there is no error the site will show up with HTTPS.

-    If there is no error on the site and the HTTPS is not showing up on the address bar, most likely there is image/link that have the HTTP hard coded which you can check by using chrome and press F12 on your keyboard to launch the developer tools to check.  

-    However if there are error shown on the page, you may revert to the working site condition by either pressing on your keyboard ctrl + z to undo (assuming you have not close the code edit page) or copy and paste the code from the .htaccess file you downloaded earlier.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.