I\'ve had to update my .htaccess from this:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
to this:
To make it work in both environments you can combine both conditions:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ 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]