htaccess SetEnv REDIRECT_前缀 [英] htaccess SetEnv REDIRECT_ prefix
问题描述
我在htaccess文件中设置了一个环境变量,并且以"REDIRECT_"开头.据我所知,这是由URL重写引起的.实际上,我没有做任何重写(我知道).
I'm setting an environment variable in an htaccess file and it's being prepended with "REDIRECT_". As far as I've read, this is caused by URL rewriting.. the thing is, I'm not doing any rewriting (that I'm aware of).
我的网站空间包含两个文件:
My webspace contains two files:
.htaccess
SetEnv Foo "bar"
index.php
<?php
print_r($_ENV);
现在,我猜测,这可能与以下事实有关:该文件位于与1& 1共享的托管程序包中.还有其他我需要检查的内容吗?以前经历过这个?还是我只是想念些东西?
Now, I'm guessing this may have something to do with the fact that this is on a shared hosting package with 1&1.. is there anything else I should be checking or has anyone experienced this before? Or am I just missing something??
欢呼
推荐答案
使用 PHP作为CGI包装器触发了此问题.如果PHP作为mod_php apache模块运行,则不会在变量前添加前缀.
The issue is triggered by using PHP as a CGI Wrapper. If PHP is running as mod_php apache module it's not prefixing your variables.
原因是内部重定向处理,因此apache使用REDIRECT_前缀重新创建变量:-/
Reason for that is internal redirect handling thus apache recreates the variables with the REDIRECT_ prefix :-/
使用PHP-FPM或mod_php
Use PHP-FPM or mod_php
如果您想使用CGI Wrapping for PHP,请将其放入您的.htaccess文件中:
If you wanna use CGI Wrapping for PHP put this into your .htaccess:
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
这篇关于htaccess SetEnv REDIRECT_前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!