2

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

2

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.' – Steven smethurst Oct 28 '11 at 20:00
  • 1
    Read server's logs for 500 error description. Can also show relevant part of config – Lazy Badger Oct 29 '11 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 Jul 10 '17 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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