How to redirect HTTP traffic to HTTPS using an .htaccess file

Redirecting HTTP to HTTPS using .htaccess

So you have installed your SSL Certificate and now you want to use it. Paste the following code to the beginning of your .htaccess file to redirect all non-https to https.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Was this helpful?