这个 HTTP 授权重写规则有什么作用?

发布于 2024-10-16 18:59:21 字数 317 浏览 5 评论 0原文

我的网站上某处存在 Google Bot 导致的重写递归错误,但我找不到导致该错误的网址,因为我的日志级别较低。我提出了,但到目前为止还没有再发生过。

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

所有重写规则对我来说看起来都很好,并且都有 [L] 标志,除了这个。

我不太明白。它来自开源商店系统Magento。

据我所知,它除了设置环境变量 E 之外什么也没做。但这不是一种非常愚蠢的方法吗?如果这是目标,你不应该使用 SetEnv 吗?

I have an rewrite recursion error somewhere on my website that Google Bot caused, but I can't find the url that caused it because my Loglevel is low. I raised it but it has not happened again so far.

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

All Rewriterules look fine to me and have the [L] flag, except this one.

I can't quite understand it. It is from the open source shop system Magento.

As far as I can tell it does nothing but sets the environment variable E. But isn't that a very stupid way of doing that? Shouldn't you use SetEnv if that was the goal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

可是我不能没有你 2024-10-23 18:59:21

Symfony 开发者小组对此有一个很好的答案。我引用:

看起来您的主机正在将 php 作为 fcgi 运行,而不是像您的本地主机那样作为 php5_module 运行。 ( phpinfo - 服务器 API:CGI/FastCGI )

重点是 php5_module 自动处理 HTTP_AUTHORIZATION 标头,但 fcgi_module 不会。

解决方案很简单 - 将此行添加到托管服务器上的 .htacces 中:

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

它对我有用

Symfony developers Group has a good answer for it. I quote:

it looks like your hosting is running php as a fcgi, not a php5_module, like your localhost does. ( phpinfo - Server API: CGI/FastCGI )

the point is that php5_module automatically handles HTTP_AUTHORIZATION headers, but fcgi_module does not.

solution is simple - add this line to your .htacces on your hosting server:

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

It worked for me

莫相离 2024-10-23 18:59:21

此行将环境变量设置为用户身份验证字符串的值 - 本质上是设置一个变量而不是常量值。据我所知,SetEnv 和 SetEnvIf 只允许您将环境变量设置为预定常量。

正在设置的变量实际上是 HTTP_AUTHORIZATION,而不是 E。我猜这是用户身份验证过程的一部分。

This line is setting the environment variable to the value of user authentication string - essentially setting a variable rather than constant value. As far as I know, SetEnv and SetEnvIf only allow you to set an environment variable to a predetermined constant.

The variable being set is actually HTTP_AUTHORIZATION, not E. I would guess this is part of the user authentication process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文