I set an environment variable in httpd-vhosts.conf
SetEnv EARLY_VAR 1
I try setting special rules based on its value in
Looking at the documentation of SetEnv directive, I notice:
Sets an internal environment variable, which is then available to Apache HTTP Server modules, and passed on to CGI scripts and SSI pages.
which means that the environments are then available to other modules. Whereas,
directive is provided by the core. This can be confirmed if you try to see whether the environment is empty during the
clause:
SetEnv TEST_VAR if_branch
or
SetEnv TEST_VAR if_branch
both will give you:
string(1) "1" string(9) "if_branch"
in your PHP.
There is also the following caveat listed on the Apache's environment variables wiki/docs pages:
The
SetEnv
directive runs late during request processing meaning that directives such asSetEnvIf
andRewriteCond
will not see the variables set with it.