Reputation: 11
I have multiple directories that look something like this:
root
- directory 1
- directory 2
- directory 3
- sub directory 1
- sub directory 2
- sub directory 3
Root is protected with a .htaccess right now,
What im looking to do is Protect sub directory 1,2, and 3 with different usernames / passwords
Can this be done? If so how?
Right now my .htaccess file that is located in directory 3 looks like this:
AuthUserFile path/path/path/sub directory 1/ .htpasswd
AuthUserFile path/path/path/sub directory 2/ .htpasswd
AuthUserFile path/path/path/sub directory 3/ .htpasswd
AuthName "Please Log In"
AuthType Basic
require valid-user
however it doesnt work...and im getting Internal Error Server
Upvotes: 0
Views: 1220
Reputation: 143886
You need a separate htaccess file in each of your subdirectories that point to the specific htpassword file. You can't separate which sub directories use which htpasswd file like you have in your htaccess.
Additionally, don't leave spaces in the page, apache will think you're referring to multiple parameters for a directive.
So in the htaccess file in each subdirectory, try something like:
AuthUserFile .htpasswd
AuthName "Please Log In"
AuthType Basic
require valid-user
but note, it's generally a really really bad idea to leave your password file in the webroot, allowing people to possibly download it.
Upvotes: 3