Friday, 13 July 2018

HTTP to HTTPS redirect Using htaccess

Create .htaccess file in your public_html folder if not exists. Add following conditions in it to redirect from http to https.

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

If Apache version is below 2 use this

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]


No comments:

Post a Comment