问题描述
有没有一种方法来在.htaccess中有条件地执行的php_flag语句?这里有两件事情我想要做的:
Is there a way to conditionally execute php_flag statements in .htaccess? Here are two things I'm trying to do:
打开错误报告。如果客户端的IP地址,我使用的IP地址相匹配:
Turn error reporting on if the client's IP address matches the IP address I use:
if %{REMOTE_ADDR} == '12.34.56.78' then
php_flag error_reporting 1
else
php_flag error_reporting 0
关闭 register_globals的
如果IP地址匹配我的,让我可以调试所造成的code期待本打开的任何问题。
Turn off register_globals
if the IP address matches mine, so that I can debug any issues caused by the code expecting this turned on.
if %{REMOTE_ADDR} == '12.34.56.78' then
php_flag register_globals on
else
php_flag register_globals on
感谢您的阅读!
Thanks for reading!
推荐答案
嘉里,
我怀疑你的第一次尝试,问题是你的常规的前pression是 ^ 192 \ .168 \ .0 $
。这将不会匹配任何可能的REMOTE_ADDR,因为你只得到了3部分的IP地址,用强制 ^
开始和 $
结束。
I suspect that the problem with your first attempt is that your regular expression is "^192\.168\.0$
". This will never match any possible Remote_Addr since you've only got 3 parts to the IP address, with a forced "^
" start and "$
" end.
也许你打算使用常规EX pression ^ 192 \ .168 \ .0 \
Perhaps you intended to use the regular expression "^192\.168\.0\.
" ?
请注意,我已经排除了 $
结尾,所以,它并没有多么的IP地址结束。而且,我已经包含一个额外的 \
越狱时间,让你强制匹配的IP地址,有一个实际的 0
,而不是像 012
, 001
等(我不是说这些零填充的部位应该是present在任何IP地址)。
Note that I've excluded the "$
" at the end, so that it doesn't matter how the IP address ends. And that I've included an extra "\.
" escaped period so that you'll force the matching IP addresses to have an actual "0
" and not something like "012
", "001
", etc (not that these zero-filled parts should be present in any IP address).
这篇关于在.htaccess条件的php_flag声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!