<Location> 和 <Directory> Apache 指令之间的区别

rfg*_*ral 39 directory httpd.conf apache-2.2

我安装了 Zend Server 并注意到我的 httpd.conf 文件中添加了如下内容:

<Location /ZendServer>
 Order Allow,Deny
 Allow from 127.0.0.1
</Location>

Alias /ZendServer "C:\Program Files\Zend\ZendServer\GUI\html"

<Directory "C:\Program Files\Zend\ZendServer\GUI\html">
 AllowOverride All
</Directory>
Run Code Online (Sandbox Code Playgroud)

但我似乎无法理解LocationDirectory之间的区别。我更改为如下内容,这对我来说更有意义,并且仍然有效:

<Location /ZendServer>
 AllowOverride All
 Order Allow,Deny
 Allow from 127.0.0.1
</Location>

Alias /ZendServer "C:\Program Files\Zend\ZendServer\GUI\html"
Run Code Online (Sandbox Code Playgroud)

我可以保留我的更改还是应该将其恢复原状?

ipo*_*gaj 50

Directory指令仅适用于文件系统对象(例如 /var/www/mypage、C:\www\mypage),而Location指令仅适用于 URL(站点域名之后的部分,例如 www.mypage.com/mylocation)。

用法很简单 -Location如果您需要通过 URL 微调访问权限,您将使用,Directory如果您需要控制对文件系统中目录(及其子目录)的访问权限,您将使用。