views:

49

answers:

2

Hi

How to protect files (documents, images..) that r being sold over internet. Is it possible to Deny access to all except a particular php file that lists those documents. for instance www.mysite.com/list

dir tree:

+ myfiles
|
|--img1.jpg
|--doc.pdf

+ application
|-+controllers
  |-lister.php

Can i grant access to myfiles DIR only from www.mysite.com/lister/showfiles NOT showfiles.php

A: 

To block all web access except for url's that start with "/lister/showfiles", you need to place this .htaccess in you're web root:

RewriteEngine on 
RewriteRule !^lister/showfiles - [F] 
Kdeveloper
+1  A: 

.htaccess file is responsible for client access only.
you can't use .htaccess to block scripts from accessing files.
it is your script logic responsible for such control.

to block client access to the files in the myfiles directory, just place an .htaccess with this line iin that directory:

Deny From All
Col. Shrapnel