Wednesday, April 04, 2007


在Apache2中可以用Alias VirtualPath SystemPath 来虚拟目录,可以指定到DocumentRoot之外的系统目录中。
在Apache2 默认一般是支持Alias的,所以在配置文件里用Alias /test /var/test这样来访问/var/test/目录下的文件。但在设置时发现Alias设置了之后无效,总是报You don't have permission to access /test/ on this server.这样的错误,因为语法很简单,肯定不会错,而且httpd -M也看到alias module被加载进来了,却还是不行,即使对应的/var/test目录设置为755或者是777都无法访问,所以是配置文件其他设置出问题了。

# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
# First, we configure the "default" to be a very restrictive set of
# features.
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all

这里设置了Deny from all导致了Alias无效,改成Allow或者注掉此行即可。

No comments :