Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend SetEnv in .htaccess not working

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

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]

When i echo APPLICATION_ENV in my index.php in the public folder, APPLICATION_ENV is not set.

What am i doing wrong?

Mod rewrite is enabled in apache.

like image 292
Arthur Avatar asked Apr 23 '11 13:04

Arthur


1 Answers

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.

like image 137
Brandon Rohde Avatar answered Sep 23 '22 13:09

Brandon Rohde