I am trying to pass an environment variable from .htaccess through to PHP. This works just fine on my local WAMP server, but on the server where my website is hosted, it fails without reason.
Here's my test configuration:
.htaccess:
SetEnv TEST_VARIABLE test_value
test.php:
<pre>
getenv('TEST_VARIABLE') = <?php print getenv('TEST_VARIABLE'); ?>
getenv('REDIRECT_TEST_VARIABLE') = <?php print getenv('REDIRECT_TEST_VARIABLE'); ?>
</pre>
On my local server, getting test.php correctly returns:
getenv('TEST_VARIABLE') = test_value
getenv('REDIRECT_TEST_VARIABLE') =
But on the production server, it returns:
getenv('TEST_VARIABLE') =
getenv('REDIRECT_TEST_VARIABLE') =
Things I've ruled out:
mod_envis not installed/enabled by the host. Can't be, because thenSetEnvwould not be recognized and I'd get a 500 while processing the .htaccess.AllowOverridesinhttpd.conffor this directory doesn't includeFileInfo. Can't be, because then Apache would throw an error "SetEnv not allowed here" when encountering theSetEnvdirective and I'd get a 500 again.variables_orderin php.ini doesn't include 'E'. This would explain the$_ENVsuperglobal being empty (which it is), but not whygetenv()doesn't return values for these variables.Entire environment is screwed up. Can't be, because
getenv('PATH')andgetenv('SERVER_NAME')still return valid values.
At this point I'm at a loss as to what configuration could be causing this.