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 fileRedirect website from http to https

  1. Login into your site cpanel.
  2. Open File Manager and get into public_html directory (check the option show hidden files).
  3. Select .htaccess file and open with code editor.
  4. Copy and Paste the below code in the starting of the .htaccess file.
  5. 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?

Leave A Comment?