Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been using MediaTemple's GridService as a production environment for a couple of relatively lightweight PHP sites. The process of setting up testing and staging environments is kind of cumbersome and leads to staff taking shortcuts, so I'm trying to put together a quality control environment that provides a similar environment to GridService but that allows me to hook it more closely to our automated deployment process (provisioning new environments in GridService requires you to use the web interface; mod_vhost_alias would just allow us to create directories that are subdomains of our test url).

I am very, very close, but encountered an issue - with PHP running as CGI, apache automatically prepends REDIRECT_ to any variables I set in .htaccess (remember, I'm simulating GridService) using SetEnv. For example:


SetEnv HTTP_TEST_VAR "Some Value"


echo getenv('HTTP_TEST_VAR'); // prints ""
echo getenv('REDIRECT_HTTP_TEST_VAR'); // prints "Some Value"

This wouldn't be a big deal (we could code around it), except that it doesn't happen in GridService, and I really would prefer to have identical code paths (adding switching logic to the code would defeat the point of all the work we've done to get configuration out of the codebase).

For the rest of the background, I'm using a brand new (2 weeks old) (ve) instance running Ubuntu, got apache and all dependencies from apt, and built PHP (5.3.15) using the configure string from a <?php phpinfo() ?> on GridService, minus db4 support.

I would really appreciate any help. Thanks!

share|improve this question
up vote 2 down vote accepted

Don't know will it be a good solution, but PHP running in FastCGI mode (mod_fastcgi) runs OK with SetEnv variables without prepending it with REDIRECT_.

Had the same issue with PHP running in CGI mode, solved by switching to FastCGI.

share|improve this answer
Thanks Andrei - I was beginning to suspect that might work. It wasn't really easy to find documentation on this feature. I'll give it a shot and see what I find. – Kurt Aug 16 '12 at 17:10

I don't think you can change this behaviour with php-cgi as in effect it is a redirect. Note though that the php getenv() function return value

Returns the value of the environment variable varname, or FALSE if the environment variable varname does not exist.

so you can easily construct a function that returns the value whether it's REDIRECT_ or not.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.