PDA

View Full Version : Password Protecting files


koala
10-20-2001, 09:44 AM
As I understand things, the .htaccess file, when placed in a directory, requires a valid user/pass to access that directory, and that this information is stored in an .htpasswd file.

Does anyone know of a script which can also read the .htpasswd file to verify the login information, but which can be used to protect individual pages (eg: protected.html) instead of the entire directory?

I use Account Manager Lite (http://cgi.elitehost.com/) to allow site visitors to register. Their login information is stored in .htpasswd and retrieved by .htaccess.

This works fine, but doesn't allow me to protect individual pages, only the directory containing them.

Can anyone help here?

Thanks

Simon

Arthur
10-20-2001, 10:59 AM
To protect individual files you would add the <FilesMatch> (http://httpd.apache.org/docs/mod/core.html#filesmatch) directive to .htaccess, example;
<FilesMatch "protected.html">
AuthUserFile /big/dom/xyourdomain/password
AuthName Protected
AuthType Basic
require user me
</FilesMatch> This would only password protect the file protected.html. With a regular expression, you can protect types of files, e.g. only .html files <FilesMatch "\.(html)$">.

HTH,
Arthur

dank
10-20-2001, 11:12 AM
Doh, what Arthur said... That's what I get for taking the time to check my notes before posting. :)

Dan

Arthur
10-20-2001, 11:18 AM
:rasberry:

koala
10-21-2001, 07:01 AM
Thanks Arthur and (almost) Dan :)

Just what I was after :D

Simon