如何添加多个用户和登录凭据,以便多个用户可以使用其特定凭据访问目录?假设我希望他们都能够访问目录/about/team/
.htaccess:
AuthType Basic
AuthName "Please enter the username and password"
AuthBasicProvider file
AuthUserFile /path/.htpasswd1
Require user user1
AuthType Basic
AuthName "Please enter the username and password"
AuthBasicProvider file
AuthUserFile /path/.htpasswd2
Require user user2
AuthType Basic
AuthName "Please enter the username and password"
AuthBasicProvider file
AuthUserFile /path/.htpasswd3
Require user user3
.htpasswd
user1: 123%%^sample-passwordHJGH&^
user2: 456%%^sample-passwordHJGH&^
user3: 789%%^sample-passwordHJGH&^
感谢
指定一个身份验证块并使用Require valid-user
。例如:
AuthType Basic
AuthName "Please enter the username and password"
AuthBasicProvider file
AuthUserFile /absolute/file-path/to/.htpasswd
Require valid-user
请注意,AuthUserFile
的文件路径是一个绝对的文件系统路径。
参考:
- https://httpd.apache.org/docs/2.4/howto/auth.html#lettingmorethanonepersonin