Many times we install SSL from cPanel but website doesn't show SSL. It is a lot of trouble. So today I will teach you how to easily run a website on HTTPS through .htaccess file.
Let's begin:
First login to your cPanel. Then scroll down a bit and go to File Manager option. Then select "Public_html".
Then click on the Settings button on the upper right side and select "Show Hidden File" and submit.
Then you will get a new file named ".htaccess" in your file. Click and hold on the set and click on the "Edit" button.
Then follow the rules below:
If you want to HTTPS on all domains, then add the following code and "Save".
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
If you want to do HTTPS on a specific domain, then add the following code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain1.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
If you want to do HTTPS in a specific folder, add the following code and save.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(folder1|folder2|folder3) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
That's it, you're done.