【问题标题】:Localhost, subdomain, using XAMPP本地主机,子域,使用 XAMPP
【发布时间】:2015-04-26 10:13:56
【问题描述】:

我是一名网络开发人员,经常想在我的本地计算机上查看不同的项目。目前我的本地主机设置为“C:/xampp/htdocs/”。我想创建一个指向“C:/xampp/htdocs/company/”的“company.localhost”。

我已编辑 c:\windows\system32\drivers\etc\hosts 以包含该行

127.0.0.1 company.localhost

我已编辑 c:\xampp\apache\conf\extra\httpd-vhosts.conf 以包含

<VirtualHost *:80>
    ServerName company.localhost
    ServerAlias company.localhost
    DocumentRoot "C:/xampp/htdocs/company/"
    DirectoryIndex index.php index.html index.htm index.shtml
</VirtualHost>

当我在浏览器(使用 Chrome)中导航到 http://company.localhost 时,它会显示本地主机索引页面。我已经启动并重新启动了我的 Apache 服务器。如何在浏览器中访问 c​​ompany.localhost/index.php?

我在 Windows 7 上。

编辑:现在http://localhosthttp://company.localhost 都指向 company.localhost 的索引页。如何恢复正常的 localhost 索引并仍然为 company.localhost 保留正确的索引页面?

谢谢。

【问题讨论】:

  • 也许有帮助,在 Windows 上使用 \ 而不是 /
  • 我正在复制 vhosts 文件中的示例,但我会试一试。编辑:现在它告诉我网页不可用。
  • 使用反斜杠而不是正斜杠会导致 Apache 突然停止的错误。
  • Soz,我不是 apache 的大师。但这很奇怪,我正在使用 windows 和 xampp 并使用那个斜线。让我们等待有人来帮助你:)

标签: php windows-7 xampp


【解决方案1】:

在同一端口上创建多个虚拟主机时,必须指定每个主机名。否则,您只有一个站点绑定到端口 80,并且所有 localhost 调用都将指向您指定的文件夹。

这是缺少的代码,在 c:\xampp\apache\conf\extra\httpd-vhosts.conf 中类似代码之前或之后添加。

<VirtualHost *:80>
    ServerName localhost
    ServerAlias localhost
    DocumentRoot "C:/xampp/htdocs/"
    DirectoryIndex index.php index.html index.htm index.shtml
</VirtualHost>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-24
    • 1970-01-01
    • 2020-09-14
    • 2011-11-12
    • 1970-01-01
    • 2012-10-21
    • 1970-01-01
    • 2016-07-30
    相关资源
    最近更新 更多