Force redirect to HTTPS using .htaccess file in PHP


Before starting anything, Let’s have a look on Introduction of .htaccess

If you have SSL installed on your domain, but how to force redirect your website to HTTPS as opposed to the non-SSL version i.e. HTTP? Today, TechnoGripper India will demonstrate to you proper guidelines to force redirect https using the .htaccess file on the root folder to guarantee that your website always redirected to  HTTPS.

Code to force redirect to HTTPS using .htaccess file:

All web traffic can be forced redirect to HTTPS by inserting the mentioned code into the .htaccess file on your website root folder. These lines should be included on the top of the file over any other code with a similar starting prefix:

How to add force HTTPS Code in the .htaccess file:

Follow these steps to add force HTTPS Code in the .htaccess file:

Step 1: Login into Web Hosting Cpanel with your username & password.

Step 2: Find “File Manager” and click on it.

Step 3: Find public_html directory. And then search for the .htaccess file in the public_html directory itself.

Step 4: If .htaccess file is not there. Create a new file with the name .htaccess & embedded the above code in the .htaccess file.

It’s done. That’s all.

Thanks for your valuable time. Stay tuned with TechnoGripper India at Community for more Interesting & Informative Articles.

Don’t hesitate to ask any question related to Core PHP, WordPress, Opencart, HTACCESS, HTML 5, Bootstrap, Angular JS, Ajax, J-Query. We are as TechnoGripper India here to help you.

2 thoughts on “Force redirect to HTTPS using .htaccess file in PHP

  1. It’s really a nice and useful piece of info.
    I’m glad that you simply shared this useful information with us.
    Please keep us informed like this. Thanks for sharing.

Leave a Reply

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

Social profiles