apache2apache2.4directory-listing

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


Solution

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