日期:2014-05-17  浏览次数:20762 次

设置apache日志记录蜘蛛爬行 转自百度HI

apache日志为什么不记录百度蜘蛛?这个问题相信很多初学者都基本碰到了,apache日志默认是不记录百度蜘蛛、谷歌和各大搜索引擎的蜘蛛程序的,但只需要修改一个地方就可以解决这个问题,现在就直接将答案写出来:
比如曾经有个朋友在百度知道中提问:
<IfModule log_config_module>
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined
LogFormat “%h %l %u %t \”%r\” %>s %b” common
<IfModule logio_module>
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %I %O” combinedio
</IfModule>
CustomLog “logs/access.log” common
</IfModule>
这是我目前的设置,不记住主机名
哪位给我提供个范本 记录访问明细和主机头记录蜘蛛的

1、打开httpd.conf文件找到以下部分:
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined

LogFormat “%h %l %u %t \”%r\” %>s %b” common

LogFormat “%{Referer}i -> %U” referer

LogFormat “%{User-agent}i” agent

具体有关LogFormat的用法请参照:

2、接着我们继续向下移动,找到虚拟主机配置段,也就是VirtualHost段,这个是由你自己来配置的。本站的虚拟主机的日志文件是这样设置的:
如果你想记录百度蜘蛛的访问全称,就按色部分设置:

CustomLog /var/html/faq/logs/linux520-access.log combined

如果不想记录百度蜘蛛的头部分,则如下设置:

CustomLog /var/html/faq/logs/linux520-access.log common

按照以上设置一下,看看你的日志文件是否发生变化了。

?

文章了链接源自:http://hi.baidu.com/vbkan/blog/item/8629fa01c17ae5107aec2c41.html