How to force your website to use https instead of http via the .htaccess file

No Comments

Did you recently install a SSL Certificate for your domain and need to force access to your website via https instead of http?

This can be done using the mod_rewrite Module with the Apache HTTP Server.

Add the following code to your .htaccess file, save and refresh your website.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This permanently redirect all http request to https

Image Credits: Photo by Isis França on Unsplash.

Last Updated On March 22, 2018

Related Articles

No results found

Leave a Reply

avatar
  Subscribe  
Notify of
Menu
Copy link