Redirect http to https with htaccess

Chrome and firefox have started to show warning to visitors when the SSL is not installed on the website. Additionally, Google & all majore search engines also prefer sites that use https (SSL) i.e. giving better chances of ranking well in search results (SEO benefits).

There are many benefits of using SSL / https – now le’s talk about how you can get SSL for your website. You can purchase a standard SSL in the market that will roughly cost around $10/year.

Good news for Easyhost Web Hosting customers – all our web hosting packages include Free SSL and Domain, instant saving! Easyhost automatically install SSL on all its web hosting plans within 24 hours of activation of service – FREE SSL!

How to redirect all traffic from http to https in 5 minutes

When your SSL is installed, the best approach is to keep a unified https link for visitors to see your site – inorder to do this, add below given code block to .htaccess file:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]

(change yourdomain.com with your actual domain name)

How to add code to .htaccess file

Follow the steps given below to redirect all your traffic to https version:

  • Login to cPanel
  • Navigate to Files > File Manager
  • From top right section, opt to “Show Hidden Files (dotfiles)
  • Find .htaccess file and select to edit (if the file doesn’t exist already, create one)
  • Add above given to .htaccess file and click “Save Changes”
  • Close the .htaccess and try your website with http version and it should direct you to https version! All done!!!

Leave a Reply

Your email address will not be published. Required fields are marked *