Redirect From HTTP to HTTPS with .htaccess


The ability to redirect from http to https using the htaccess file may be essential in how your business converts on your website.

What are .htacess files?

.htaccess files are configuration files used to modify web software running on Apache Servers.  Moving sites over to HTTPS is now critical for all website, not explicitly ecommerce stores.

How to redirect from HTTP to HTTPS through .htaccess

Using the following code in the .htaccess file located in your root directory.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  • If you have a pre existing .htaccess file there is no need to copy “RewrightEngine On” again as this is required once only.
  • Please ensure ReqriteCond and RewriteRule directly follow RewriteEngine On

Common issues faced.