Force redirect to HTTPS using .htaccess file in PHP

July 17, 2017
14 Shares 523 Views
Like Love Haha Wow Sad Angry

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.

Like Love Haha Wow Sad Angry



One Response

  1. Pingback: Remove .php and .html extensions from URL using htaccess – Community

Leave a Comment

Your email address will not be published.