thecommonthread
thecommonthread

Reputation: 405

htaccess different user permissions for different users

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?

Upvotes: 0

Views: 450

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

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.

Upvotes: 1

Related Questions