views:

63

answers:

2

I have a private folder on my domain like

http://example.com/protected

and i stored lot of images and pdf file there

 /protected/pad1.pdf
 /protected/pad2.pdf
 /protected/pad1.png
 /protected/pad1.png

supose these are the files, how can i hide or protect access to there files with the help of .htaccess file.

allow only users those who knows the password.

is it possible ???

+5  A: 

Check out Apache's page on Authentication, Authorization and Access Control -- one method would be using Basic or Digest authentication. That would look something like this:

AuthType Digest
AuthName "Private files"
AuthDigestFile /usr/local/apache/passwd/digest
Require user (usernames here)

Of course, you need to generate a password and/or digest file using htdigest or htpasswd as well, but that procedure is explained in the document I linked to.

You
+1  A: 

Or for zero configuration and zero access:

Order Allow, Deny
Deny From All

=)

Alix Axel
-1. As you said, zero access.
You
He wants to *hide* or protect. Why -1?
Alix Axel
He said "allow only users those who knows the password" -- implying *someone* needs access to the files.
You
Don't truncate, it's bad.
Alix Axel
It's a perfectly valid answer. "Zero access" in this case means zero access through HTTP. You could set up FTP access to the folder to allow downloading of the files - although in that case you'd be better off moving them outside the web root...
DisgruntledGoat