【问题标题】:This site can’t be reached - XAMPP ignores custom domain vhosts无法访问此站点 - XAMPP 忽略自定义域虚拟主机
【发布时间】:2019-09-17 08:12:42
【问题描述】:

环境

  • XAMPP 7.2.4 安装在 Windows 10 上
  • Apache 在端口 80 和 443 上运行

配置

C:\Windows\System32\drivers\etc\hosts

127.0.0.1 www.test.local test.local

C:\xampp\apache\conf\httpd.conf

DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>

C:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot D:/htdocs
    ServerName localhost
    <Directory "D:/htdocs">
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot D:/htdocs
    ServerName test.local
    <Directory "D:/htdocs">
        Allow from all
    </Directory>
</VirtualHost>

问题

当我启动 Apache 并访问 localhost 时,一切正常。当我尝试访问test.local 时出现问题:浏览器返回无法访问此站点 消息。就像 XAMPP 忽略了在 httpd-vhost.conf 文件中定义的自定义域虚拟主机。在服务器关闭时显示相同的消息。

This site can’t be reached 
The webpage at http://test.local/ might be temporarily down or it may have moved permanently to a new web address.
ERR_ADDRESS_INVALID

几天前,设置工作正常,我所做的唯一更改是新软件安装。我的意思是,Apache 配置文件没有变化。

【问题讨论】:

  • 你确定上面没有包含test.local的其他行吗?试试ping test.local
  • ping 返回来自127.0.0.1 的响应,并且没有重复的行。

标签: apache xampp vhosts hosts


【解决方案1】:

您是否使用这样的映射更新了您的 C:\Windows\System32\drivers\etc\hosts 文件?

  • 将此行添加到hosts 文件的末尾
127.0.0.1 test.local
  • localhost 域无需此映射即可工作,因为操作系统已将“localhost”识别为环回 IP 地址的内置别名

(此建议假设您在同一台本地机器上运行和测试)

【讨论】:

  • hosts 文件没问题。这些天我意识到这可能是一个防病毒问题......
【解决方案2】:

如果您之前的所有堆栈都正常工作,请不要像我一样,不要忘记检查某些浏览器扩展程序是否阻止了您的本地流量,例如与防病毒系统相关的某些扩展程序.

就我而言,它是卡巴斯基保护扩展。当出现问题时,它会显示以下图形。

【讨论】:

  • 哈哈傻了我,谢谢你救了我,我突然遇到了这个奇怪的问题,我一无所知,我忘了我出于某种原因启用了 VPN,然后当我尝试访问我的本地域时它不能,在搜索了几分钟后找到了你的解决方案,它对我有用:) 再次感谢
【解决方案3】:

C:\Windows\System32\drivers\etc

127.0.0.1   test.local

C:\xampp\apache\conf\extra\httpd-vhosts.conf:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "C:/wamp64/www/test"
    ServerName test.local
    <Directory "C:/wamp64/www/hydroboost/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-03
    • 1970-01-01
    • 2017-12-29
    • 2015-08-05
    • 2015-06-24
    • 2012-12-28
    • 2022-07-22
    相关资源
    最近更新 更多