0

here's what I aim to do. I have in my public folder numerous folders like images, css, javascript and I want to deny access to these folders but not files within them. Which seemed easy but then there're all those sub folders in the images folder like icons, photos and users which has a sub folder for each user and this task became a little pain in the neck. Since I failed to deliver in a single htaccess file my only option left was to create an index.php in every sub folder and hope for the best. That's why I'm asking if someone can provide a recursive way to limit access to all sub folders but not files within them with a single htaccess file? I'm using apache.

php_nub_qq
  • 15,199
  • 21
  • 74
  • 144
  • do you want to prevent directory listing for all folders? if yes then just add " Options -Indexes " directive in your htaccess – Amine Hajyoussef Jun 09 '13 at 17:17
  • Awesome! That's exactly what I needed! But is there also a way I can redirect those requests to some other page instead of just displaying FORBIDDEN? Also please answer that so I can +rep and accept! Thanks :P – php_nub_qq Jun 09 '13 at 17:56

1 Answers1

3

to prevent access to directories add the following directive to .htaccess

Options -Indexes

you can customize the forbidden page by:

ErrorDocument 403 /somepage.php
Amine Hajyoussef
  • 4,381
  • 3
  • 22
  • 26
  • Do you mind please throwing an eye to this question, I have given a little more details there. http://stackoverflow.com/questions/17012875/apache-structure-issue-htaccess Never thought a relative path can be this much of a struggle – php_nub_qq Jun 09 '13 at 18:46