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

前端 未结 2 522
旧巷少年郎
旧巷少年郎 2020-11-29 18:31

I\'ve had to update my .htaccess from this:

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

to this:

2条回答
  •  时光说笑
    2020-11-29 18:46

    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]
    

提交回复
热议问题