#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    9
    Rep Power
    0
    Is it possible to protect a file and also a sub directory using different password files? As I am now, everytime I enter a password to access the file, or the directory, I can access both the file and the directory.

    This is not what I am interested in doing. I want one or the other, otherwise 2 passwords have to be entered to get both.

    Is this possible?

    Thanks,

    Tim
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Yes. If you have access to httpd.conf, use <LocationMatch>. If not, use <FilesMatch> in your .htaccess file.

    <FilesMatch "somefile.html$">
    AuthName "Dimman Site"
    AuthType Basic
    AuthUserFile /path/to/.htpasswd
    require valid-user
    </FilesMatch>
    <FilesMatch "anotherfile.html$">
    AuthName "Dimman Site"
    AuthType Basic
    AuthUserFile /path/to/another/.htpasswd
    require valid-user
    </FilesMatch>

    The known bug of using FilesMatch for your purpose is that, if the same file is found under the subdirs of your .htaccess, it will also match and prompt for login. Using <LocationMatch>, however, give you exact URL match.

    <LocationMatch "^/private/anotherfile.html$">

IMN logo majestic logo threadwatch logo seochat tools logo