dongpanshi2839 2011-11-19 19:39
浏览 65

我希望忽略或不记录“文件不存在”错误

[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

[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

Solved thanks

  • 写回答

1条回答 默认 最新

  • douxiangbiao1899 2011-11-19 19:46
    关注

    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]
    

    In case you don't have any pattern for the URLs and you want to prevent for all non-existing files, add a RewriteCond:

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

    Or just with a more current apache:

    FallbackResource /index.php
    

    and then index.php giving a 404 status response:

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

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

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

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

    See: Apache2: how to avoid logging certain missing files into error.log

    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题