Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable "Cannot serve directory" errors

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.

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

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

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).

like image 776
JemoeE Avatar asked Oct 27 '25 10:10

JemoeE


2 Answers

LogLevel autoindex:crit

I solved this by moving up the log level for autoindex module.

like image 149
Bohan Yang Avatar answered Oct 29 '25 01:10

Bohan Yang


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.

like image 30
covener Avatar answered Oct 29 '25 01:10

covener