Apache SetEnv prepends REDIRECT_ . What gives?

喜欢而已 提交于 2019-12-01 14:59:16

问题


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

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?


回答1:


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.




回答2:


I had the same issue and it was because of was running PHP as cgi in my Apache.

After enabling mod_php, I could access to my variable without that prefix.



来源:https://stackoverflow.com/questions/2267976/apache-setenv-prepends-redirect-what-gives

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!