Redirect website from http to https

Here is the exact code to redirect website from http to https using .htaccess file.

After installing SSL certificate for your website. Please follow the steps mentioned below to Redirect website from http to https using .htaccess file

  1. Login into your site cpanel.
  2. Open File Manager and get into public_html directory (check the option show hidden files).
  3. If you are not able to see .htaccess file in your file directory then Click on the right side top “Settings” icon and check the option show hidden files. Now you will be able to see the .htaccess file to edit.
  4. Select .htaccess file and open with code editor.
  5. Copy and Paste the below code in the starting of the
  6. Redirect website from http to https.htaccess file.
  7. Save it and open your site in the new tab and check it, your site will be redirected from http to https.

#Redirection code starts

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Redirection code Ends

Please, comment below if your have any queries or doubts regarding to this article. Thanks

Was this article helpful?

9 Comments

  1. Julia

    To be honest this tips might be much more helpful for the beginners.

    1. Smartzworld

      Please check for the hidden .htaccess file and add the code their… Don’t create new .htaccess file

Leave A Comment?