您当前的位置:首页 > 分类 > 技术资讯 > PHP > 正文

XAMPP提示 Access forbidden情况的处理

发布时间:2016-04-19 15:44:23      来源:51推一把
【摘要】xampp中遇到403问题的解决方法,及http.conf中的参数配置说明
Access forbidden!
You dont have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
test.abc.net
Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3

当前的站点是定义在httpd-vhost.conf里的,

 <VirtualHost *:80>
 documentRoot "G:/web/www/www.test.com"
 serverName www1.test.com
 errorLog "logs/dummy-host2.example.com-error.log"
 customLog "logs/dummy-host2.example.com-access.log" combined
 <Directory "G:/web/www/www.test.com">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>
</virtualHost>

这时在httpd.conf需要加上这一段代码:
<Directory "G:/web/www/www.test.com">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>


然后重启xampp,问题解决。

==========================================================
==========================================================

APACHE中虚拟目录和虚拟主机设置

在apache的配置文件http.conf中设置如下信息,可以将该目录变成一个web可以放的目录:

Options Indexes MultiViews  FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

这里面的几个参数说明如下:

Indexes 允许目录浏览(即列出此目录下所有文件名称);MultiViews 允许内容协商的多重视图。
比如:客户端输入“http://10.0.0.1/icone/a”这将会显示此目录下所有 a.* 文件,并不是出错信息。All 包含了初MultiViews 之外的所有特性,若无Options 语句,默认为All

AllowOverride 定义对于每个目录下的 .htalless 文件中的指含类型,一般禁止使用。

设置缺省的访问权限,当前设置表示允许所有客户机都能访问。比如仅允许192.168.16.0/24 这个段能访问,除了192.168.16.5/24 之外。
使用方法:Oredr allow ,deny
Allow from 192.168.16.0/24
Deny from 192.168.16.5/24
 
注意: 即设置目录的访问的一些规则,常和虚拟目录连在一起使用

建立虚拟目录

1.找到"conf/httpd.conf" 文件
2.在httpd.conf里面加了如下语句

Alias /anstyla "E:/anstyla/src/web"
 
          Options Indexes MultiViews
          AllowOverride None
          Order allow,deny
          Allow from all

在此模块下建立虚拟目录,Alias /虚拟目录名称/ "虚拟目录路径,以[/]代替[\]"

例如:Alias /admin "D:/web/admin/"

(*)/admin 为虚拟目录名称,一般不用在名称后加"/",若加入,每次都要在虚拟目录后输入"/"才能访问网站;D:/web/admin/ 为虚拟目录的物理路径.

设置默认页面

方法1 设置全局的:
    DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml default.php

方法2 针对某一目录可以这么设置:
    Alias /anstyla "E:/anstyla/src/web"
 
          Options Indexes MultiViews
          AllowOverride None
          Order allow,deny
          Allow from all
          DirectoryIndex default.php