How to Automatically Redirect HTTP Traffic to the Secure HTTPS Using .htaccess File

Did you install SSL Certificate and still your site is loading insecurely? It could be because your site is not redirecting traffic to the scure https protocol.

1. Login to cPanel to accomplish this task.

2. Locate File Manager on the Files section.

image showing how to redirect traffic to https on cPanel

3. Open your “public_html” directory by double-clicking on it. This is where your publicly accessible files are located, in other words, where your website files resides.

image showing how to redirect traffic to https on cPanel

4. Locate the file called “.htaccess“. If you cannot see that file, it could be that you have not enabled the display of hidden files on your file manager. Files that start with a dot(.) are hidden files. To activate the display of hidden files, click on “settings” at the top right corner.

image showing how to redirect traffic to https on cPanel

A popup will appear. Tick to show hidden files and save.

image showing how to redirect traffic to https on cPanel

If after choosing to display hidden files you cannot find it, it means you do not have the file. Just create it by clicking on the “+File” icon and name it .htaccess.

image showing how to redirect traffic to https on cPanel

5. Click on the file to select it then click on “edit” at the top navigation menu.

image showing how to redirect traffic to https on cPanel

6. A popup will appear, just click on the button “edit”.

image showing how to redirect traffic to https on cPanel

7. Put the following content inside the file and save the changes:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule ^(.*)$ //www.example.com/$1 [R,L]

Please note: i) Replace “example” with your real domain name. ii) If you had the “.htaccess” file before, chances are that it has the line “RewriteEngine On”. If that is the case please do not add another instance of it, just ignore the first line and start from the second one.

About the Author
HostPinnacle Kenya
HostPinnacle Kenya is the best and cheapest web hosting company in Kenya with world-class web hosting packages and affordable web design offers. Apart from that we offer free life-time SSL certificate, affordable domain registration in Kenya and free whois privacy. We have an award-winning support team available 24/7/365 to help you with your queries.

Leave a Reply

CALL ME
+
Call me!
WhatsApp WhatsApp us