I have a web application developed in PHP. My requirement is to block a folder which contains uploaded documents. For example, if a user click a document link on the application, it should open http://localhost:1987/enterprise_resource_planning/uploads/students/documents/1499866795_100_100.pdf if a user execute below url, it should block http://localhost:1987/enterprise_resource_planning/uploads/students/documents/ I've tried .htaccess with Deny from all, but it is blocking everything. Any solution for this senario ?
Asked
Active
Viewed 329 times
-1
-
`deny from all` - well that would be why it blocks everything, you need to set your server files and folders to certain permisisons and user groups as well as using htaccess for restriction - but not using deny from all – treyBake Jul 13 '17 at 13:27
-
you mean, you do not want to see a listing of all files? – Ivo P Jul 13 '17 at 13:27
-
1Maybe a `.htaccess` in that folder that contains `Options -Indexes` – RiggsFolly Jul 13 '17 at 13:28
-
Yes exactly. I dont want to see a listing on web browser if I execute http://localhost:1987/enterprise_resource_planning/uploads/students/documents/ – Stanly Simon Jul 13 '17 at 13:28
-
The only way for this to be php-related is if you create a `index.php` in the uploaded files folder. – simlev Jul 13 '17 at 13:30
-
I am using WAMP server – Stanly Simon Jul 13 '17 at 13:33
-
Avoid the use of .htaccess files and configure your virtual hosts instead. – Kurt Van den Branden Jul 13 '17 at 13:36
1 Answers
2
possible solutions:
- place a file index.html or index.php in the directory
- define in your httpd.conf
Options -Indexes
- place that line in .htaccess
personnally I prefer the 2nd line. There hardly ever is use for automatical listing of the files to a browsing visitor.

Ivo P
- 1,722
- 1
- 7
- 18