Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop people from viewing contents of a directory

I want to stop people from viewing the contents of my images directory. I've built an app using Codeigniter and notice that they just have index.html pages with a 403 Forbidden message in all directories - is this a secure method to use? Is an index.html page in the directory sufficient or do I need to update config or .htaccess?

like image 832
pingu Avatar asked Dec 04 '25 21:12

pingu


2 Answers

The .htaccess solution should work if you're comfortable using it.

Options -Indexes

If you are on a shared host with cPanel, you can change your settings in Index Manager

Cpanel - Index Manager

like image 169
Sid Avatar answered Dec 07 '25 14:12

Sid


The index.html should be enough and secure, but it is not really a clean solution, because it is not actually returning a error message, it is probably still returning HTTP 200 and then showing the html page with error 403.

The clean solution would be adding

Options -Indexes

to the .htaccess file.

like image 27
Brutos Avatar answered Dec 07 '25 15:12

Brutos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!