| |
编辑httpd.conf 设置如下:


SetEnv IMAG 1

CustomLog logs/access_log combined env=!IMAG

这样记录文件access_log就不会记录ico|gif|jpg|png|bmp|swf的访问记录,同样也可以加上css|js才过滤css和js文件,效果很好.
但是这种记录限制只限制于做虚拟主机的时候没有同时设定记录文件的时候会参照这个方式记录在access_log文件里.不过httpd.conf里默认还有另外一个类似不记录虚拟主机日志的日志文件.

(设定:服务器是windows20003,装有apache2.3 php5 mysql zend gd)

参照:
    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per- access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog logs/access.log common
这样会重复记录一个文件access.log ,所以可以注释掉上面那一行:
#CustomLog logs/access.log common

好了,现在Apache日志不记录图片文件设置原理方法已经知道了,但是虚拟主机里面的日志文件格式是什么呢?
先看我的虚拟主机的原来的配置内容:


ServerAdmin daniel1228@gmail.com
DocumentRoot E:\web\viatop
ServerName  viatop.cn
ServerAlias *.viatop.cn
ErrorLog logs/viatop.cn-error_log
CustomLog logs/viatop.cn-access_log common

看看日志文件viatop.cn-access_log里面还是记录了图片的访问记录,也就是上面说的那个配置对在虚拟主机里设置的日志文件不起作用.

为什么会这样呢?
其实不是不起作用,而是作用域没有应用到而已,现在我改为:

ServerAdmin daniel1228@gmail.com
DocumentRoot E:\home\user\web\viatop
ServerName  viatop.cn
ServerAlias *.viatop.cn
ErrorLog logs/viatop.cn-error_log
CustomLog logs/viatop.cn-access_log combined env=!IMAG


这样就好了,虚拟主机里面的日志文件也不会记录图片的访问记录了.

by ocean | 分类: 网络学院 » LAMP | 评论(0) | 引用(0) | 阅读(281)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]