【问题标题】:Disable "Cannot serve directory" errors禁用“无法提供目录”错误
【发布时间】:2017-06-04 04:53:40
【问题描述】:

在我的网站上,我有一个 /upload 目录。而且我希望人们看到目录中的内容列表(其中的文件仍然可以查看) - 所以对我来说以下错误消息不是错误。

有没有办法禁用以下错误消息,同时保持 /upload 目录列表被禁用/禁止?

[autoindex:error] [pid 17883] [client IP:16603] AH01276: Cannot serve directory /var/www/my-site.com/upload/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

我不希望它出现在我的 error.log 中,因为我不认为这是一个错误。

我想我可以在目录中创建自己的“禁止”index.html 文件,但这个问题是针对多个文件夹的,所以我宁愿不这样做(如果可能的话)。

【问题讨论】:

    标签: apache2 apache2.4 directory-listing


    【解决方案1】:

    您可以将受影响的目录与例如重写规则并匹配尾部斜杠并返回 [F] 或 [G],这将是无声的。否则,无法直接在 mod_autoindex 中或在某个日志记录层间接抑制消息。

    【讨论】:

    • 编辑:RewriteRule ^upload/$ - [F]
    【解决方案2】:
    LogLevel autoindex:crit
    

    我通过提升自动索引模块的日志级别解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2016-06-18
      • 2021-06-21
      • 2020-04-03
      • 2021-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      • 2021-12-19
      相关资源
      最近更新 更多