Is there a way to conditionally execute php_flag statements in .htaccess? Here are two things I\'m trying to do:
Turn error reporting on if the client\'s IP address matc
if %{REMOTE_ADDR} == '12.34.56.78' then php_flag error_reporting 1 else php_flag error_reporting 0
This is only really possible with the advent of Apache Expressions in Apache 2.4+, where you can do just this sort of thing...
php_flag error_reporting 1
php_flag error_reporting 0
If on Apache 2.2 this is not really possible, especially with something that is dependent on the request, like the REMOTE_ADDR
. On Apache 2.2 you have
, but this only tests the existence of parameters that have been defined on the Appache command line with the -D
option. So, this is really a per-server configuration switch. (On Apache 2.4 you can use the Define
directive in the server config to define parameters somewhat conditionally, however, this still can't be defined based on elements of the request AFAIK. Besides, you have the use of Apache Expressions on Apache 2.4 anyway.)