Apache 每个域有不同的htpasswd文件

Apache 每个域有不同的htpasswd文件,apache,.htaccess,authentication,basic-authentication,.htpasswd,Apache,.htaccess,Authentication,Basic Authentication,.htpasswd,我有两个域,例如foo.com和bar.com,它们共享相同的文档根。 这些站点受.htaccess文件保护 AuthUserFile ../.htpasswd AuthName "No Access" AuthType Basic <Limit GET POST PUT> require valid-user </Limit> 如何根据主机设置AuthUserFile 伪代码: 如果这是不可能的,有没有其他方法可以为这两个域获得不同的登录?尝试如下设置: #s

我有两个域,例如foo.com和bar.com,它们共享相同的文档根。 这些站点受.htaccess文件保护

AuthUserFile ../.htpasswd
AuthName "No Access"
AuthType Basic
<Limit GET POST PUT>
    require valid-user
</Limit>
如何根据主机设置AuthUserFile

伪代码:


如果这是不可能的,有没有其他方法可以为这两个域获得不同的登录?

尝试如下设置:

#site1.com
setenvIfNoCase Host site1\.com pass_1
AuthType Basic
AuthName "Site1.com Login Required"
AuthUserFile "/home/userdir/.htpasswds/site1.pwd"
Require valid-user
Order allow,deny
Allow from all
Deny from env=pass_1
Satisfy any

#site2.com
setenvIfNoCase Host site2\.com pass_2
AuthType Basic
AuthName "Site2.com Login Required"
AuthUserFile "/home/user_dir/.htpasswds/site2.pwd"
Require valid-user
Order allow,deny
Allow from all
Deny from env=pass_2
Satisfy any

这不管用。它总是使用第二部分。我认为它完全覆盖了第一个。
#site1.com
setenvIfNoCase Host site1\.com pass_1
AuthType Basic
AuthName "Site1.com Login Required"
AuthUserFile "/home/userdir/.htpasswds/site1.pwd"
Require valid-user
Order allow,deny
Allow from all
Deny from env=pass_1
Satisfy any

#site2.com
setenvIfNoCase Host site2\.com pass_2
AuthType Basic
AuthName "Site2.com Login Required"
AuthUserFile "/home/user_dir/.htpasswds/site2.pwd"
Require valid-user
Order allow,deny
Allow from all
Deny from env=pass_2
Satisfy any