问题描述
对于基于 Zend Framework 的应用程序,我在 .htaccess
中使用了 apaches SetEnv
.我在测试、登台和生产服务器上使用它,如下所示:
For an application based on Zend Framework I use apaches SetEnv
in .htaccess
. I use this on test, staging and production servers like so:
SetEnv APPLICATION_ENVIRONMENT production
在临时服务器上,我无法在 PHP 中读取此环境变量.但是,当我在 php 中执行 var_dump( $_ENV )
时,我得到了值,但键前面加上了 REDIRECT_
成为
On the staging server I couldn't read this env var in PHP. However when I did a var_dump( $_ENV )
in php I got the value but the key was prepended with REDIRECT_
becoming
REDIRECT_APPLICATION_ENVIRONMENT
谁能解释为什么会发生这种情况,以及我如何防止这种情况发生?
Can anybody explain why this is happening, and how I can prevent this?
推荐答案
我猜你的 .htaccess 中也有用于 Zend 的 mod_rewrite 规则?我相信这可能是 mod_rewrite 在它进行重定向时预先设置的,这样该值就不会被具有新 URL 的任何新设置覆盖.
I'm guessing you have mod_rewrite rules in your .htaccess as well for Zend? I believe it may be mod_rewrite prepending that when it does a redirect so that the value won't be overridden by any new settings with the new URL.
这篇关于Apache SetEnv 在 REDIRECT_ 前面.是什么赋予了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!