How to Force SSL with htaccess

this needs to be done for several proposes

Now days web security require each domain to use Secure Socket Layer SSL certificate. There are plenty available on the market from free to ones very expensive. Check our blog if you need to install SSL on your domain or on WHM server.

Now when you have SSL on your domain you need to route all the traffic via HTTPS protocol. This needs to be done for several proposes:

  • to ensure all traffic is encrypted and secure
  • to avoid double content pages (titles and meta descriptions)

To force an HTTPS connection on a website just add these simple rules in your website's .htaccess file:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This .htaccess file must be placed inside a website's document root folder. If website is in a sub folder, then the .htaccess should be placed in the corresponding sub folder.

Sergio Avatar

Sergio Sviridov

Information Delivery Specialist


SEO, Design and Marketing Blog

Comprehensive Guide to Local SEO
Comprehensive Guide to Local SEO
What is Brickseek and How to Use It
What is Brickseek and How to Use It
Bing Places Benefits for Local Business Listings
Bing Places Benefits for Local Business Listings

Number of Total Worldwide Registered Domains Updated: Jul 31 2021