需要有关Xampp虚拟主机的帮助 [英] need help with xampp virtual host

查看:106
本文介绍了需要有关Xampp虚拟主机的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XAMPP,Apache 2.2.17.我已经添加了虚拟主机,但是我的虚拟主机和本地主机都指向同一位置.这是我在httpd-vhosts.conf

I am using XAMPP, Apache 2.2.17. I have added virtual host but my virtual host and localhost both point to the same location. Here is my code in httpd-vhosts.conf

<VirtualHost www.domain.tld:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot "C:/xampp/htdocs/workspace/testsite"
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/xampp"
   ServerAlias localhost
   ServerName localhost
</VirtualHost>

使用上面的代码,我通过www.domain.tld获得了测试站点,这很好.但是,如果我键入localhost,它也会进入testsite.如果我移至测试站点之前,则localhost转到localhost良好,而www.domain.tld也转到localhost.我尝试为localhost设置不同的设置,例如

With the above code, I get testsite with www.domain.tld so that is good. But If i type localhost, it will go to testsite as well. If I move ahead of test site then localhost goes to localhost good and www.domain.tld goes to localhost too. I tried different setting for localhost as like

<VirtualHost *>
<VirtualHost localhost:80>

,然后从domain.tld中删除* .domain.tld,但没有任何效果.我缺少明显的东西吗?

and removing *.domain.tld from domain.tld but nothing works. Am I missing something obvious?

推荐答案

我自己的答案:以下代码解决了该问题

My own answer: The following code fixed the problem

<VirtualHost *:80> <--- * fixed the problem, apache 2.2 doc does say it must match www.domain.tld, which caused problem for other Virtual hosts
ServerName www.domain.tld
ServerAlias domain.tld 
DocumentRoot "C:/xampp/htdocs/workspace/patriot2"
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/xampp"
   ServerAlias localhost
   ServerName localhost
</VirtualHost>

这篇关于需要有关Xampp虚拟主机的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆