Apache 2.4 允许访问受密码保护的目录

Apache 2.4 允许访问受密码保护的目录

我真的很难用新方法来实现这一点,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/*# 

已发挥作用

相关内容