I have a directory with several sub directories. I found this article Preventing Directory Listing that shows me how to prevent people from getting the directory listings.

IndexIgnore *

But it produces a bad error page, (it looks like an empty directory listing). Instead I would like to redirect the user to a page or show a better error page when they try to view the directory listings of a sub directory.

I am using Apache

1 Answer 1


Try this:

Options -Indexes
ErrorDocument 403 /path/to/403.html
  • I get a 403 error. I checked that my 403.html document exists and is publicly available. I also used the full path. 'Forbidden You don't have permission to access /files/2011/ on this server. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.' Commented Oct 28, 2011 at 20:00
  • 1
    Read server's logs for 500 error description. Can also show relevant part of config Commented Oct 29, 2011 at 4:02
  • If you get a 500 error then it suggests the error document is not "publicly available" and you probably have a conflict with existing directives in your .htaccess file. The error documents need to be accessible without restriction - this will sometimes mean adding additional conditions to your .htaccess file (or server config) to make this so.
    – MrWhite
    Commented Jul 10, 2017 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.