禁用 "Cannot serve directory" 个错误

Disable "Cannot serve directory" errors

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

有没有办法在保持 /upload 目录列表 disabled/forbidden 的同时禁用以下错误消息?

[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 中,因为我不认为它是错误的。

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

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

LogLevel autoindex:crit

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