Php_flag conditional instructions in .htaccess

Is there a way to conditionally execute php_flag instructions in .htaccess? Here are two things I'm trying to do:

Enable error reporting if the client's IP address matches the IP address used:

if %{REMOTE_ADDR} == '12.34.56.78' then php_flag error_reporting 1 else php_flag error_reporting 0 

Disable register_globals if the IP address is the same as mine so I can debug any problems caused by code waiting to be turned on.

 if %{REMOTE_ADDR} == '12.34.56.78' then php_flag register_globals on else php_flag register_globals on 

Thanks for reading!

+6
php apache .htaccess
source share
1 answer

Kerry

I suspect that the problem with your first attempt is that your regular expression is " ^192\.168\.0$ ". This will never match any remote Remote_Addr, since you only have 3 parts of the IP address, with a forced start of " ^ " and " $ ".

Perhaps you intended to use the regular expression " ^192\.168\.0\. "?

Note that I excluded " $ " at the end, so it doesn't matter how the IP address ends. And that I included an extra " \. " Shielding period, so you make the corresponding IP addresses have the actual " 0 ", and not something like " 012 ", " 001 ", etc. (not that these zero parts must be present on any IP address).

+1
source share

All Articles