解决Wamp 开启vhost localhost 提示 403 Forbbiden 的问题!

3 篇文章 0 订阅
2 篇文章 0 订阅

很奇怪的一个问题,我以前从来都没有这样过!访问 http://localhost/ 提示  403 Forbbiden。


我之前的设置一直都是这样的:

httpd.conf

<Directory />
    AllowOverride All
	Options Indexes FollowSymLinks
    Require all granted
</Directory>

extra/httpd-vhost.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "d:/localhost"
    ServerName localhost
    ServerAlias local
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>


<VirtualHost *:81>
    ServerAdmin webmaster@localhost
    DocumentRoot "d:/wamp/www"
    ServerName localhost81
    ServerAlias local81
    ErrorLog "logs/localhost81-error.log"
    CustomLog "logs/localhost81-access.log" common
</VirtualHost>

然后 d:/localhost/ 与  d:/wamp/www 目录下都没有索引文件(如 index.html index.php index.html)以前访问都是默认列出目录的,但是今天打开localhost 却提示403 无权限。

而且修改vhost ,调换 80 端口和 81 端口位置还是这样,百思不得其解!


强迫症,花费了一个下午的时间研究仍旧是没有头绪,晚上回到家里,偶然看到stackoverflow上的一个帖子,http://stackoverflow.com/questions/9110179/adding-virtualhost-fails-access-forbidden-error-403-xampp-windows-7,尝试着修改第一个VirtualHost,在里面加入 <Directory "d:/localhost"> ... </Directory> 重启Apache,可以了。


<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "d:/localhost"
    ServerName localhost
    ServerAlias local
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
	<Directory "d:/localhost">
	Options Indexes
	Require all granted
	</Directory>
</VirtualHost>


但是我后来将这一段去掉,然后又重启,访问 http://localhost 又变成可以访问了。等于我还原了所有修改,再去访问localhost 却又不会出现提示 403 Forbbiden了!



而且我将httpd.conf 的<Directory /> ... </Directory>的这一段去掉Options Indexes 这一段,改成如下,再重启Apache:

<Directory />
    AllowOverride All
    Require all granted
</Directory>

我访问 http://localhost/ 或者 http://localhost:81,目录还是可以列出来,出鬼了!!




认为wamp 似乎有缓存,而且重启也无法清除?重装也是无法清除。

现在问题并没有再次重现,但如果您有彻底的解决方法,欢迎邮件交流。by default.fu@foxmail.com




  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值