How to force redirect http to https using .htaccess

how to force http to https redirection htaccess

If you have an SSL certificate installed and would like to force your website to load with https URL – you may add the following code in the .htaccess file (Linux based hosting):

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

You need to place the .htaccess file in the home directory of your website.


Leave a Comment