【问题标题】:setup a virtualhost on localhost在 localhost 上设置虚拟主机
【发布时间】:2011-10-20 18:26:44
【问题描述】:

我正在跟踪线程以在 stackoverflow 上设置虚拟主机。我确实关注了

<VirtualHost *:80>
    ServerAdmin timy@yt.com
    DocumentRoot "C:/www/test"
    ServerName test.devsite-1.com
    ServerAlias test.devsite-1.com
</VirtualHost>

在 Windows 主机文件中

127.0.0.1   test.devsite-1.com

我在浏览器中点击了以下网址

http://test.devsite-1.com/

结果页面显示文件夹列表,即 localhost 页面...正如我所期望的那样,它将显示 /test 文件夹中 index.php 的内容?

如果我的解释有误,有人可以纠正我吗?

问候

【问题讨论】:

    标签: virtual localhost


    【解决方案1】:

    如果您看到的是测试文件夹的内容,那么您可能需要将 index.php 定义为索引。

    您可以先尝试在目录中使用 index.html 文件,但我相信您在 Virtualhost 配置中缺少 DirectoryIndex 指令。

    尝试添加:

    DirectoryIndex index.html index.php
    

    到您的虚拟主机配置。

    【讨论】:

      【解决方案2】:

      尝试添加

      DirectoryIndex index.php
      

      到您的虚拟主机。

      顺便说一句:我建议您使用某种 test.devsite-1.local,这样您就不会意外阻止真正的 test.devsite-1.com。

      【讨论】:

        猜你喜欢
        • 2015-01-06
        • 2015-11-08
        • 2014-05-22
        • 2018-05-16
        • 2011-02-09
        • 2017-08-12
        • 2023-04-06
        • 2020-07-17
        • 2014-09-26
        相关资源
        最近更新 更多