禁用“无法提供目录"错误 [英] Disable "Cannot serve directory" errors

查看:28
本文介绍了禁用“无法提供目录"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On my website I have an /upload dir. And I don't want people to see a list of the content in the dir (the files in it can still be viewed) - so to me the following error message is not an error.

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

Is there a way to disable the following error message, while keeping /upload Directory Listing 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 中,因为我不认为它是一个错误.

I don't want it to be in my error.log since I don't consider it an error.

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

I guess I could make my own "Forbidden" index.html file in the dir, but this problem is for multiple folders, so I rather not (if possible).

推荐答案

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

You could match the affected directories with e.g. RewriteRule and match against the trailing slash and return [F] or [G], which would be silent. Otherwise, it is not possible to suppress the message directly in mod_autoindex or indirectly at some logging layer.

这篇关于禁用“无法提供目录"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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