apache HTTP:X-Forwarded-Proto in .htaccess 导致开发环境中的重定向循环 [英] apache HTTP:X-Forwarded-Proto in .htaccess is causing redirect loop in dev environment

查看:40
本文介绍了apache HTTP:X-Forwarded-Proto in .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 Elastic Load Balancer 后面工作.

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-Forwarded-Proto in .htaccess 导致开发环境中的重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆