How to redirect website to https using .htaccess file?

by SA Admin May 1 in Linux Command 0 Comments 49 Views

How to redirect website to https using .htaccess file?
Here, are some simple code to redirect http website to https using .htaccess file:


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

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


If you face any issue then just comment on this log in comment section. Our team provide your better assistance.