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?

+2


a source to share


3 answers


Htaccess solution should work if you're comfortable using it.

Options -Indexes
      



If you are using a shared host using cPanel, you can change your settings in the Index Manager

Cpanel - Index Manager

+4


a source


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.

+2


a source


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.

+1


a source







All Articles