How to 301 Redirect HTTP to HTTPS Using htaccess? Non-secure to Secure

! Not Secure 

This message dosent look good next to your domain url on a web browser. To make your website secure, you need to install an SSL certificate.

If you have installed your SSL certificate and still you are getting the above message, then you simply have to redirect you http to https using the .htaccess file in the root directory of the web server. 

Here is a complete guide to redirecting http to https using .htaccess.

Nowadays, HTTPS is a necessity. It symbolizes trust. A warning appears when a visitor loads a website running on HTTP in Google Chrome, Firefox, and other popular browsers. Sites marked as unsecure are marked as such.

The importance of using secure sockets for eCommerce stores cannot be overstated.

Using .htaccess, I will show you how to force a redirect from HTTP to HTTPS in this post.

Using cPanel File Manager, edit the .htaccess file:

  1. Open your cPanel account
  2. Click on File Manager from the Files Tab
  3. Find the “Setting” at the top right corner of the page, click on it
  4. Click on the Document Root for (the domain name) and check the Show Hidden Files (image below)
  5. Save to update the File Manager
  6. Find the public_html file and click on it
  7. On the next page, you will find the .htaccess file
  8. Click once on the .htachess file and then click on the “Edit” at the top bar
  9. A warning box will pop up, but click on Edit
  10. On the next page, a code editor will open
  11. Edit the code
  12. Save the file

Redirect HTTP to HTTPS

Redirect All Web Traffic

Add this code below the existing code in your .htaccess file.

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$$1 [R,L]