How to redirect non secure URL to secure (from http:// to https://) using .htaccess file

#First rewrite any request to the wrong domain to use the correct one (here www.)

RewriteCond %{HTTP_HOST} !^www\.

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

 

#Now, rewrite to HTTPS:

RewriteCond %{HTTPS} off

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

  • 220 Users Found This Useful
Was this answer helpful?
Related Articles
Copyright © 2020 Temok IT Services. All Rights Reserved.
Positive SSL