的Apache HTTP:X-转发,原在.htaccess导致在开发环境重定向循环重定向、环境、Apache、HTTP

由网友(烈酒焚心)分享简介:我已经从这个更新我的.htaccess:I've had to update my .htaccess from this:RewriteCond %{HTTPS} !=onRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]这样:RewriteC...

我已经从这个更新我的.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]
阅读全文

相关推荐

最新文章