需要xampp虚拟主机的帮助吗

需要xampp虚拟主机的帮助吗,xampp,virtualhost,Xampp,Virtualhost,我使用的是XAMPP,Apache2.2.17。我添加了虚拟主机,但我的虚拟主机和本地主机都指向同一位置。这是我在httpd-vhosts.conf中的代码 <VirtualHost www.domain.tld:80> ServerName www.domain.tld ServerAlias domain.tld *.domain.tld DocumentRoot "C:/xampp/htdocs/workspace/testsite" </VirtualHost>

我使用的是XAMPP,Apache2.2.17。我添加了虚拟主机,但我的虚拟主机和本地主机都指向同一位置。这是我在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
ServerAlias domain.tld*.domain.tld
DocumentRoot“C:/xampp/htdocs/workspace/testsite”
DocumentRoot“C:/xampp/htdocs/xampp”
服务器别名本地主机
服务器名本地主机
通过上面的代码,我获得了带有www.domain.tld的测试站点,这很好。但如果我键入localhost,它也将转到testsite。如果我先于测试站点,那么localhost将转到localhost good,而www.domain.tld也将转到localhost。我尝试了不同的localhost设置,如下所示

<VirtualHost *>
<VirtualHost localhost:80>


并从domain.tld中删除*.domain.tld,但没有任何效果。我是否遗漏了一些明显的内容?

请将您的服务器名从virtualhost更改为本地IP地址,如127.0.0.2


ServerName domain.tld是使用“domain.com”的一个示例,其中,域的.tld被.com替换。

我自己的答案:以下代码修复了该问题

<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>
名称虚拟主机*:80
DocumentRoot C:/xampp/htdocs
服务器名本地主机
ServerName mydomain.local
ServerAlias www.mydomain.local
DocumentRoot C:/mysite/htdocs

我以前试过127.0.0.1,但没有成功。你能看看我的问题兄弟吗?你能看看我的问题兄弟吗?
NameVirtualHost *:80

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

<VirtualHost *:80>
    ServerName mydomain.local
    ServerAlias www.mydomain.local 
    DocumentRoot C:/mysite/htdocs
</VirtualHost>