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

Charles Thomas from Usa:
 Hello, this is Charles over at stage-3 and I wanted to say thanks for all your support. I'm new at operating my business online and boy an I learning something new. Thanks to the support from EGN I was able to get the site up much faster. I have a long way to goand I know I can count on them when I need help. Thanks Guys, Charles Thomas aka....The Mail Man 

Latest News

Accepted Payments

Copyright © 2007 - 2026 EGN Software, All rights reserved

Talk to us?