如何从我的 apache 访问日志中排除 img 文件?我无法让它工作。我试图添加这个
## flag robots.txt requests
SetEnvIf Request_URI "^/robots\.txt$" robots-request=log
## flag favicon requests
SetEnvIf Request_URI "^/favicon\.ico$" favicon-request=nolog
## flag image requests
SetEnvIf Request_URI "(\.gif|\.png|\.jpg)$" image-request=nolog
## flag Css and JS requests
SetEnvIf Request_URI \.css css-request=nolog
SetEnvIf Request_URI \.js js-request=nolog
## flag cron calls
SetEnvIf Request_URI "(^/cron\.php|^/bgp-start/)" cron-request=nolog
## set do_not_log if any of the above flags are set
SetEnvIf robots-request nolog do_not_log
SetEnvIf favicon-request nolog do_not_log
SetEnvIf image-request nolog do_not_log
SetEnvIf css-request nolog do_not_log
SetEnvIf js-request nolog do_not_log
SetEnvIf cron-request nolog do_not_log
我将此添加到我的 apache2.conf
将指令 SetEnvIf 和 CustomLog 添加到 vhost 配置中,例如:
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
SetEnvIf Request_URI "\.png$|\.gif$|\.jpg$|\.js$|\.css$" is_exclude
CustomLog ${APACHE_LOG_DIR}/access.log combined env=!is_exclude
</VirtualHost>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句