php - 本地主机,子域,使用 XAMPP

标签 php windows-7 xampp

我是一名网络开发人员,经常想在我的本地机器上查看不同的项目。目前我的本地主机设置为“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>

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

我在 Windows 7 上。

编辑:现在都是http://localhosthttp://company.localhost指向 company.localhost 的索引页。如何取回正常的本地主机索引并仍然保留 company.localhost 的正确索引页?

谢谢。

最佳答案

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

这里是缺少的代码,在 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>

关于php - 本地主机,子域,使用 XAMPP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28701731/

相关文章:

Git 在写入我正在 pull 的文件时给我一个 "Permission Denied"错误

vim - 如何在 Windows 7 中关闭 gvim 中的所有字体提示?

php - 如何修复 PHP 错误 : Unable to get local issuer certificate?

php - "Your message has been successfully sent using the following protocol: mail",但我什么也没得到

php - 约定表名(带下划线)

php - 从数据库检索数据并分解并基于该选择复选框

php - php inside html和反之亦然的区别

php - 按指定顺序选择匹配行前后的行

windows-7 - 使用Powershell脚本作为启动外部程序的登录脚本(组策略)?

php - 无法在 wamp 中通过 Web 表单插入,但它在 xampp 中有效