When we installing SSL certificates to a website, we need to change the urls with the prefix https. Even we changed prefix to https, almost all servers won’t automatically redirect the http requests to https. Both will work as standalone. So we need to redirect it manually using a .htaccess file.

Steps

  1. Login to cPanel/FTP
  2. Move to the public_html folder/site root folder
  3. Create a file with name .htaccess
  4. Insert the below code to it.
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

Leave a Reply

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