After installing an SSL certificate, your website is available over HTTP and HTTPS, but it’s recommended to use only the latter because it encrypts and secures your website’s data. This article will show you how to force HTTPS using your File Manager.
Forcing HTTPS on All Traffic
You can activate the feature to force HTTPS on all incoming traffic by following these steps:
1. Log in to your cPanel account
2. Go to the File Manager. You can scroll down to the Files section or use the search bar to find it
3. On the public_html folder, look for the .htacces file. Right click on it and select Edit
4. This window will show up. Just click on Edit
5. Add the following code at the top of the file
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
6. Click the Save Changes button on the top right. You will see a Success message, you can now close the editor
Forcing HTTPS on a Specific Domain
You can also force HTTPS on one single domain. If that’s the case, follow the steps above but use the following code on step 5.
RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain1.com [NC] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
It should look like this:
Forcing HTTPS on a Specific Folder
The .htaccess file can also be used to force HTTPS on specific folders. However, the file should be placed in the folder that will have the HTTPS connection. Follow the steps above and replace the code on the step 5 with the following:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(folder1|folder2|folder3) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
It should look like this:
If you are a Host Duplex customer and still have questions, please open a ticket in the Host Duplex client portal.