Website general: How to Force HTTPS using .htaccess
Search:
How to Force HTTPS using .htaccess

After installing an SSL certificate, your website is available over HTTP and HTTPS. However, it’s better to use only the latter because it encrypts and secures your website’s data. You can use the .htaccess file to force HTTPS connection to your website. This tutorial will show you how.

 

Forcing HTTPS on All Traffic

One of the many functions you can perform via .htaccess is the 301 redirects, which permanently redirects an old URL to a new one. You can activate the feature to force HTTPS on all incoming traffic by following these steps:

  1. Go to File Manager in your hosting panel and open .htaccess inside the public_html folder (If you can’t find the file, go to the  Settings on the upper right menu and tick the Show Hidden Files option to enable viewing)
  2. Insert the following lines of code:
        RewriteEngine On 
        RewriteCond %{HTTPS} off 
        RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
  3. Save the changes.

 

IMPORTANT: Make sure that the line RewriteEngine On is not repeated twice. In case the line already exists, simply copy the rest of the code without it.

Congratulations! you have successfully edited your .htaccess file and redirected all HTTP traffic to HTTPS, the safe version of your website.

 

Other tutorials in Website general:

 

Popular Tutorials:


Testimonial

Renato from Australia:
 Hi there EGN Software, I have bought a couple of your products in the past, and currently the Viral Shop script. My experience has been very good support, and all questions answered as needed. In addition, the products seem to work very well. Have not noticed any problems. Lots of thought, and design went into this script, and its very feature packed. This does not happen fast, but takes a lot of hard work and effort to produce a good product. I would like to recommend EGN Software. I setup the Viral Shop script and its working fine, and this is a very good company to deal with, no problems with them. Due to my privacy I have not displayed my email address for public viewin... 

Latest News

Accepted Payments

Copyright © 2007 - 2026 EGN Software, All rights reserved

Talk to us?