的Apache HTTP:X-转发,原在.htaccess导致在开发环境重定向循环 [英] apache HTTP:X-Forwarded-Proto in .htaccess is causing redirect loop in dev environment
本文介绍了的Apache HTTP:X-转发,原在.htaccess导致在开发环境重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经从这个更新我的.htaccess:
I've had to update my .htaccess from this:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
这样:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
要得到它的工作背后AWS Elasic负载平衡器。
to get it working behind an AWS Elasic Load Balancer.
这一切似乎很好地工作在AWS上,但在我的本地环境我被困在一个重定向循环。
It all seems to work fine on AWS, but in my local environment I'm stuck in a redirect loop.
我如何能得到这个设置在两种条件下正常工作?
How I can get this setup to work correctly in both environments?
推荐答案
要使其在两个环境中工作,你可以结合两个条件:
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]
这篇关于的Apache HTTP:X-转发,原在.htaccess导致在开发环境重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文