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

Charlie Burnette from United States:
 Hi Everyone I have been working with online programs for several years. And, just wanted you to know that, Script4profit and EGN hosting have been, by far, the best script and hosting service that I have ever used. Their staff and customer service have been top-notch. And, they have always responded helpfully and quickly to answer any questions and to help with any needs I have ever had. I Highly recommend their services! 

Latest News

Accepted Payments

Copyright © 2007 - 2026 EGN Software, All rights reserved

Talk to us?