所以,每当用户试图抓取我的Apache服务器上不存在的文件,我在Access日志中得到一个404行:
[29/Sep/2010:12:14:45 +0200] "GET /asdf HTTP/1.1" 404
我也在错误日志中得到这个:
[Wed Sep 29 12:14:45 2010] [error] [client] File does not exist: /www/site/asdf
有没有一种方法可以抑制404错误在访问日志中的错误日志中显示?
ErrogLog( http://httpd.apache.org/docs/2.2/mod/core.html#errorlog )没有条件。 您可以将日志发送到系统日志或脚本并对其进行过滤。
是的,你可以从错误日志中取消它们,但仍然在访问日志中 。 只需将这些行添加到.htaccess:
# Don't log missing files RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(content\asdf)$ - [R=404,L]
它使用mod_rewrite。
RewriteCond在那里,以确保该文件确实不存在。 存在的文件将照常服务。
当客户端访问任何包含“asdf”的文件时,R = 404表示发送404 Not Found状态码。 您需要修改括号中最后一行的expression式,以满足您的需求。
这个答案也在这里find。
尝试试用LogLevel指令( http://httpd.apache.org/docs/current/mod/core.html#loglevel )。 这不完全是你想要的,但它可以满足你的需求
错误404是在httpd.conf或.htacces中定义的,如下所示:
ErrorDocument 404 /404.html
您可以redirect到索引页面:
ErrorDocument 404 /index.html
或者您可以创build一个空白页面blank.html并将configuration更改为:ErrorDocument 404 /blank.html