Apache 2.4 在子域上需要密码似乎不起作用

Apache 2.4 require password on subdomain not seems to be working

我的最后一个小马驹是在每个子域上作为密码,但不是 www 和本地。

I followed the https://httpd.apache.org/docs/trunk/howto/auth.html guide. "Visitors coming from that address will not be able to see the content covered by this directive. If, instead, you have a machine name, rather than an IP address, you can use that."

AuthType Basic
AuthName "Password Required"
<If "req('Host') == 'dev.domain.ee'">
    AuthUserFile /path/dev/.htpasswd
</If>
<If "req('Host') == 'test.domain.ee'">
    AuthUserFile /path/test/.htpasswd
</If>
<If "req('Host') == 'prelive.domain.ee'">
    AuthUserFile /path/prelive/.htpasswd
</If>
<RequireAll>
    Require all granted
    Require not host dev.domain.ee test.domain.ee  prelive.domain.ee
</RequireAll>

在 dev.domain.ee

上不询问密码仍然不起作用

我找到了解决我自己问题的方法。

<RequireAny>
     Require host www.domain.ee
     Require local
     Require valid-user
</RequireAny>

这表明除了 localhost 和 www.domain.ee

之外的所有其他情况都需要有效用户