October 13, 2019

How to force SSL & HTTPs with .htaccess on your site

Back to Solutions

Now that HTTPs is a major requirement, you will need to enforce this on your site. You can force SSL or HTTPs very easily via the file .htaccess.

To force SSL, you will need to make sure Mod_Rewrite is enabled on your server. Edit your .htaccess file and add the code below.

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

If your .htaccess file had already the first line i.e. RewriteEngine On, do not add it again.

Was this solution helpful?

Related Solutions

7-Day Website

Professional site, live in one week. Built to convert visitors into customers.

Your website. Live in 7 days or less. Starting at $999.

Enterprise Solutions

Complex requirements? We've built platforms handling 10M+ requests daily.

Let's architect something your competitors can't copy.

GemPixel