Stop people from browsing directory contents
I want to prevent people from browsing the contents of my image directory. I created an app using Codeigniter and noticed that they just have index.html pages with 403 message forbidden in all directories - is this a safe method to use? Is the index.html page in the directory sufficient or do I need to update the config or .htaccess?
a source to share
index.html should be sufficient and safe, but it's not really a clean solution because it doesn't actually return an error message, it probably still returns HTTP 200 and then shows an html page with a 403 error.
A clean solution would be to add
Options -Indexes
to the .htaccess file.
a source to share
In general, you need more than just index.html, depending on your server configuration, you can still get a directory listing. None of the files in the directory will be protected.
Your best bet is to update your server config to restrict access, and set the policy via .htaccess if needed. Finally, unless you want it to be served, it really shouldn't be part of the directory structure published by the server.
a source to share