Since I had to test this myself and could only confirm that what you wrote was correct, I started to look around and found this post regarding SetEnv
, SetEnvIf
and RewriteRule
visibility. It looks like SetEnv
is not visible for RewriteCond
and if I change your example to use:
SetEnvIf APPLICATION_ENV ^(.*)$ APPLICATION_ENV=development
I actually get the rules you have to load app_dev.php
. You could set the variable using RewriteRule
as well:
RewriteRule .* - [E=APPLICATION_ENV:development,NE]
However, looks like SetEnv
can't be used (Tested on Apache 2.2.22).
EDIT
As julp pointed out in a comment to this post this is quite clear in Apache document section Setting Environment Variables:
The SetEnv directive runs late during request processing meaning that directives
such as SetEnvIf and RewriteCond will not see the variables set with it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…