You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WAMP3.2.3配置虚拟主机后局域网其他设备无法访问项目如何解决

问题原因排查与解决办法

核心问题

你直接通过局域网IP访问时,Apache会按顺序优先匹配第一个虚拟主机(localhost)的规则,而localhost的目录配置里仍然是Require local,仅允许本地设备访问,因此返回403禁止错误。同时你的虚拟主机配置存在冗余符号的语法错误,可能导致配置未正常加载生效。

具体解决步骤

  • 第一步:修正httpd-vhosts.conf配置语法,补全IP访问规则
    删除配置中DocumentRoot、<Directory>行末尾多余的>符号,同时补充IP访问对应的虚拟主机规则,完整参考配置如下:
# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

# 自定义项目虚拟主机(域名访问)
<VirtualHost *:80>
    ServerName test
    DocumentRoot "c:/wamp64/www/project1/test/sites/"
    <Directory  "c:/wamp64/www/project1/test/sites/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

# 补充局域网IP访问规则,把示例IP替换为你本机的实际局域网IP即可
<VirtualHost *:80>
    ServerName 192.168.43.xxx
    DocumentRoot "c:/wamp64/www/project1/test/sites/"
    <Directory  "c:/wamp64/www/project1/test/sites/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

如果你不需要区分IP访问的站点内容,也可以直接把第一个localhost虚拟主机的Require local修改为Require all granted,无需额外新增IP虚拟主机配置。

  • 第二步:重启Apache服务
    打开WAMP控制面板,点击重启所有服务,确保修改的配置生效。

  • 第三步:验证防火墙规则
    确认Windows防火墙入站规则中已放行Apache的80端口,也可临时关闭防火墙测试访问是否正常,排除拦截问题。

  • 第四步:可选域名访问配置
    如果需要在局域网其他设备使用http://test域名访问站点,修改对应设备的hosts文件,添加一行规则192.168.43.xxx test即可,IP替换为你本机的实际局域网IP。

内容的提问来源于stack exchange,提问作者CodNoob

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 12:09:00