拒绝访问子文件夹但不访问文件
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.
这是我的目标。 我在我的公共文件夹中有许多文件夹,如图像,CSS,JavaScript,我想拒绝访问这些文件夹,但不能访问其中的文件。 这似乎很容易,但是图像文件夹中的所有子文件夹,如图标,照片和用户,每个用户都有一个子文件夹,这项任务变得有点痛苦。 由于我没有在单个htaccess文件中提供,我唯一的选择是在每个 strong>子文件夹中创建一个index.php并希望最好。 这就是为什么我问是否有人可以提供一种递归方式来限制对所有子文件夹的访问,而不是使用单个htaccess文件限制对其中的文件的访问? 我正在使用apache。 p> div>
to prevent access to directories add the following directive to .htaccess
Options -Indexes
you can customize the forbidden page by:
ErrorDocument 403 /somepage.php