How to rewrite http url to https
2 answers
Usage %{localhost}
is a problem as there is no such variable called %{localhost}
.
Try this rule in your root .htaccess or Apache:
RewriteEngine On
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{SERVER_PORT} !=443 [OR]
RewriteCond %{ENV:protossl} !=s [OR]
RewriteCond %{HTTP:X-Forwarded-SSL} !=on [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
+1
source to share