我有一个Apacheconfiguration,限制访问到一个网站,使用下面的代码 –
<Directory /var/www/html/website/test/> AuthName "Dyne Drewett Test Site" AuthType Basic AuthUserFile /usr/local/etc/apache/.htpasswd require valid-user </Directory>
有没有人知道我可以如何修改这个允许完全,未经授权的访问/test/下的一个目录? 谢谢。
更新
从@dunxd的一些帮助后,我现在有这个,我猜一定是错误的,因为我仍然得到401错误时去请求的页面(find/dyne_drewett/目录)。 任何进一步的帮助将是伟大的。
# 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>
有几个方法来实现这一点。
最简单的方法是为AuthType设置为None的子目录创build另一个目录条目,如下所示:
<Directory /test/public> AuthType None Require all granted </Directory>
另一种方法使用指向该目录的不同URL。 在目录指令的Apache文档中有一条评论说:
请注意目录path参数:它们必须与Apache httpd用于访问文件的文件系统path字面匹配。 应用于特定的指令不适用于通过不同path从相同目录访问的文件,例如通过不同的符号链接。
你可以在这里使用它 – 在/ test /下创build一个从/ allowed /到你的子目录的符号链接,并使用该URL指向该目录。