How to Force HTTPS Using the .htaccess

Redirect All Web Traffic

To force all web traffic to use HTTPS insert the following lines of code in the .htaccess file in your website's root folder.

NOTE: If you have existing code in your .htacess, add this above where there are already rules with a similar starting prefix.

 RewriteEngine On
 RewriteCond %{HTTPS} !=on
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Was this answer helpful?

0 Users Found This Useful