如何一次为Apache CustomLog强加两个条件?

我目前有静态和dynamic页面单独的访问日志。 我的httpd.conf有(在<VirtualHost>中 ):

<LocationMatch "^/(img|js|css|thumb|banner)/(.+)$"> SetEnv static 1 </LocationMatch> CustomLog /var/log/apache2/gopal.log myCustom env=!static CustomLog /var/log/apache2/gopal-static.log myCustom env=static 

我想补充它

 SetEnvIf Remote_Addr "127.0.0.1" dontlog CustomLog /var/log/apache2/gopal.log myCustom env=!dontlog 

,但找不到一个使用CustomLog expr =参数的例子,无法猜测一个工作expression式: expr=!(reqenv('static')||reqenv('dontlog'))产生

语法错误,意外的T_OP_OR

reqenv函数必须与某些东西进行比较,你不能像代码试图那样检查环境variables是否被设置。 我承认这个错误信息不是特别有启发性的:-)

以下内容适用于您:

 SetEnvIf Request_URI ^/(img|js|css|thumb|banner) static=yes SetEnvIf Remote_Addr "127.0.0.1" dontlog=yes CustomLog logs/access_log myCustom expr=!(reqenv('static')=='yes'||reqenv('dontlog')=='yes')