0

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

AuthUserFile ../.htpasswd
AuthName "No Access"
AuthType Basic
<Limit GET POST PUT>
    require valid-user
</Limit>

如何根据主机设置 AuthUserFile?

伪代码:

if (host == foo.com) {
    AuthUserFile ../.htpasswd_foo
} else {
    AuthUserFile ../.htpasswd_bar
}
AuthName "No Access"
AuthType Basic
<Limit GET POST PUT>
    require valid-user
</Limit>

如果这是不可能的,还有其他方法可以为 2 个域获取不同的登录名吗?

4

1 回答 1

-1

尝试这样设置:

#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
于 2013-07-25T14:36:14.247 回答