Apache配置虚拟目录及403错误排查
问题背景:在进行Apache配置,修改httpd.conf文件时。
尝试添加虚拟目录功能。
或者 Alias /sww/ "C:/xampp/htdocs/test/"
随后出现了限制权限访问的问题。
页面显示Access forbidden!(禁止访问)。
详细错误信息为:You don't have permission to access the requested object. It is either read-protected or not readable by the server.(您无权访问所请求的对象,它要么受读保护,要么服务器无法读取)。
提示信息建议:If you think this is a server error, please contact the webmaster.(如果您认为这是服务器错误,请联系网站管理员)。
最终报错代码为Error 403。
出错时的访问地址为localhost。
发生时间为2011/8/26 17:36:49。
服务器环境信息:Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1。
解决思路:需要添加相应的目录设置配置。
相关代码如下:
AllowOverride None
Options None
Order allow,deny
Allow from all
以下是具体的尝试过程:
1. 将C:/xampp/htdocs/test/末尾的/去掉,结果:无法启动apache。
2. 将C:/xampp/htdocs/test/末尾的/改成\,结果:无法启动apache。
3. 将C:/xampp/htdocs/test/改为"D:/Work/Booksir/BP/Code/User_Booksir_com_cn/trunk/",结果:无法启动apache。
4. C:/xampp/htdocs/test/文件夹已拥有Everyone完全控制权限,给D:/Work/Booksir/BP/Code/User_Booksir_com_cn/trunk加上Everyone的完全控制权限,结果:仍无法启动apache。
5. 将"D:/Work/Booksir/BP/Code/User_Booksir_com_cn/trunk/"末尾的/去掉,同时将/sww/末尾的/去掉,结果:成功启动apache。
结论如下:
最佳实践是
使用Alias /sww "D:/Work/Booksir/BP/Code/User_Booksir_com_cn/trunk"
后面都不要加/,都不要使用\,这样比较保险。
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a section to allow access to
# the filesystem path.