Dav*_*ard 2 directory authorization apache-2.2
我有一个 Apache 配置,它使用以下代码限制对网站的访问 -
<Directory /var/www/html/website/test/>
AuthName "Dyne Drewett Test Site"
AuthType Basic
AuthUserFile /usr/local/etc/apache/.htpasswd
require valid-user
</Directory>
Run Code Online (Sandbox Code Playgroud)
有谁知道我如何修改它以允许对/test/
. 谢谢。
更新
在@dunxd 的一些帮助之后,我现在有了这个,我猜这一定是错误的,因为在转到所请求的页面(在/dyne_drewett/
目录中找到)时,我仍然收到 401 错误。任何进一步的帮助都会很棒。
# Main directory rules
<Directory /var/www/html/website/test/>
# General access to the site
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from 192.168.1
# Authorisation settings
AuthName "Dyne Drewett Test Site"
AuthType Basic
AuthUserFile /usr/local/etc/apache/.htpasswd
require valid-user
</Directory>
# Theme directory rules
<Directory /var/www/html/website/test/wp-content/themes/dyne_drewett/>
# General access to the folder
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
# Authorisation settings
AuthType None
require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
有几种方法可以实现这一点。
最简单的方法是为AuthType设置为 None的子目录创建另一个目录条目,如下所示:
<Directory /test/public>
AuthType None
Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
另一种方法使用指向目录的不同 URL。在目录指令的 Apache 文档中有一条评论说:
注意目录路径参数:它们必须与 Apache httpd 用来访问文件的文件系统路径字面匹配。应用于特定的指令不适用于通过不同路径从同一目录访问的文件,例如通过不同的符号链接。
您可以在这里利用它 - 创建从 /allowed/ 到 /test/ 下的子目录的符号链接,并使用该 URL 指向该目录。
归档时间: |
|
查看次数: |
2251 次 |
最近记录: |