Zend SetEnv in .htaccess not working

前端 未结 5 1347
有刺的猬
有刺的猬 2021-02-08 05:07

I installed Zend on my ubuntu homeserver. In my .htaccess file i have the following code:

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQU         


        
5条回答
  •  迷失自我
    2021-02-08 05:29

    If you are running your home server on a Mac or have suEXEC enabled, there are security measures in place to strip any non-http environment variables that are defined, therefore they won't appear in $_ENV['APPLICATION_ENV']. You CAN, however access these through a PHP function to get the same thing.

    $var = apache_getenv('APPLICATION_ENV');
    

    You could even define the environment variable within PHP if you want, although not recommended.

    $_ENV['APPLICATION_ENV'] = apache_getenv('APPLICATION_ENV');
    

    I have an almost identical config to what you have, and we just define a global:

    define('APPLICATION_ENV', apache_getenv('APPLICATION_ENV'));
    

    Once you do that, it should work as desired.

提交回复
热议问题