我想和QUOT;文件不存在"被忽略或没有错误记录 [英] I want "File does not exist" errors to be ignored or not logged

查看:164
本文介绍了我想和QUOT;文件不存在"被忽略或没有错误记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[周六11月19日13时17分04秒2011] [错误] [客户端1.1.1.32]文件不
  不存在:/var/www/vhosts/x.com/httpdocs/scores.asp

[Sat Nov 19 13:17:04 2011] [error] [client 1.1.1.32] File does not exist: /var/www/vhosts/x.com/httpdocs/scores.asp

[周六11月19日13时17分54秒2011] [错误] [客户端1.1.1.32]文件不
  不存在:/var/www/vhosts/x.com/httpdocs/reqewrqwe.awwe

[Sat Nov 19 13:17:54 2011] [error] [client 1.1.1.32] File does not exist: /var/www/vhosts/x.com/httpdocs/reqewrqwe.awwe

解决感谢

推荐答案

创建的 重写规则 以及响应的URL返回一个空文件,你想从日志中删除:

Create a RewriteRule and return an empty file in response to the URLs you'd like to remove from the logs:

RewriteRule scores\.asp$ - [L]

如果你不具备的URL任何图案,你想prevent所有非现有的文件,添加的 的RewriteCond

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]

,或只与较新的Apache:

Or just with a more current apache:

FallbackResource /index.php

然后的index.php 给予404状态响应:

<?php
header("Status: 404 Not Found", 1, 404);

的index.php 文件必须存在,否则(对重写规则),这会造成一个死循环。

The index.php file must exists, otherwise (for the RewriteRule) this would create an endless loop.

另外这可能工作(并不会要求的index.php 文件):

Alternatively this might work (and won't require the index.php file):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ - [R=404,L]

请参阅:的Apache2:如何避免某些记录丢失的文件到error.log中

这篇关于我想和QUOT;文件不存在&QUOT;被忽略或没有错误记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆