我真的很难用新方法来实现这一点,2.2 很简单,这是我所拥有的:
<Directory /home/website/public_html/>
Options -Indexes
AllowOverride All
AuthType Basic AuthName "Password Protected Area" AuthUserFile /home/.passwd
<RequireAny>
<RequireAll>
Require expr %{REQUEST_URI} =~ m#^allowaccess/tothisdirectory/$#
</RequireAll>
Require user someuser
</RequireAny>
</Directory>
因此文件夹allowaccess/tothisdirectory
位于 public_html 中。整个 public_html 已成功受密码保护,但允许访问的规则allowaccess/tothisdirectory
不起作用。
答案1
Require expr %{REQUEST_URI} =~ m#^allowaccess/tothisdirectory/$#
到
Require expr %{REQUEST_URI} =~ m#/allowaccess/tothisdirectory/*#
已发挥作用