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

Mike Tyson. asked, Feb 06 ' 2015

I am using the below code but not working......

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

 

  • htaccess
  • http
  • https

1 Answers

It seems you are written on in RewriteCond

use the below code in .htaccess

RewriteEngine On

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

 

Leave a Ansewer