apache HTTP:X-Forwarded-Proto in .htaccess is causing redirect loop in dev environment apache HTTP:X-Forwarded-Proto in .htaccess is causing redirect loop in dev environment apache apache

apache HTTP:X-Forwarded-Proto in .htaccess is causing redirect loop in dev environment


To make it work in both environments you can combine both conditions:

RewriteCond %{HTTP:X-Forwarded-Proto} !httpsRewriteCond %{HTTPS} offRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]


I had a special case for a shared hosting (masterhost), everything was failing except:

  RewriteCond %{HTTP:X-Forwarded-Port} !443  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]