Force SSL/HTTPS connection (cPanel)
Posted by Simon , Last modified by Jackson on 23 June 2018 12:30 PM
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.
Once the SSL certificate has been installed, you will need to add the following code in the respective .htaccess file.
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.
- 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”.
- 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.