htaccess 和多个域的身份验证

htaccess and authentication for multiple domains

我是 运行 一个多站点 TYPO3 站点。

对于直播前的过程,我想为 3 / 4 个网站添加一个 htaccess 和一个 htpasswd

如何配置 htaccess 文件以仅针对特定 url 触发身份验证?

例如:

http://example.org 不应该得到密码保护, 而 http://example2.org 应该。

两个站点都在同一台服务器上并由 CMS 处理。

因为通常的 htaccess-stuff 看起来像这样:

AuthUserFile /path/to/my/.htpasswd
AuthGroupFile /dev/null
AuthName "Geschützter Bereich"
AuthType Basic
<Limit GET>
    require valid-user
</Limit>

每个站点都会触发。

感谢您的任何建议。

除非主机以example2.com

结尾,否则这将使其如此授权
# set the "require_auth" var if Host ends with "example2.com"
SetEnvIfNoCase Host example2\.com$ require_auth=true

# Auth stuff
AuthUserFile /var/www/htpasswd
AuthName "Password Protected"
AuthType Basic

# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
#except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth