0

I can't seem to find the proper way to write my .htaccess file. I initially had the file set up to allow access to a directory of files and that worked fine:

AuthUserFile /var/www/html/technical/mep/.htpasswd
AuthGroupFile /dev/null
AuthName "Password Protected Area"
AuthType Basic

Require valid-user

Now what I need to do is add an additional htpasswd file (something like .htpasswd2) and allow those additional user to only be able to access a single file in that directory. How do I edit my current .htaccess file to make this happen?

thecommonthread
  • 395
  • 4
  • 14

1 Answers1

1

You can simply use the <FilesMatch> container:

<FilesMatch protected.html>
  AuthUserFile /var/www/html/technical/mep/.htpasswd2
  AuthGroupFile /dev/null
  AuthName "Password Protected Area 2"
  AuthType Basic

  Require valid-user
</FilesMatch>

And the file "protected.html" would use the .htpasswd2 file.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • So I could just add this in after my code above in the same .htaccess document? Thanks for your help. – thecommonthread Jul 09 '13 at 16:04
  • @user1988799 Yeah, you can add this after what you have above. It will have precedence when the request is for the matched filename. – Jon Lin Jul 09 '13 at 16:28