需要帮助xampp虚拟主机
我正在使用XAMPP,Apache 2.2.17。我添加了虚拟主机,但是我的虚拟主机和本地主机都指向相同的位置。这是我在的httpd-vhosts.conf需要帮助xampp虚拟主机
<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。我尝试了不同的本地主机设置像
<VirtualHost *>
<VirtualHost localhost:80>
和删除*从使用domain.tld,但没有.domain.tld工作。我错过了明显的东西吗?
我自己的答案:下面的代码解决了这一问题
<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>
请将您的ServerName从虚拟主机更改为本地IP地址,如127.0.0.2。
ServerName domain.tld是使用“domain.com”的示例,其中.tld被.com替换为您的域。
我尝试过,但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>
你可以请看看我的问题bro https://*.com/questions/45173872/virtual-host-cannot-create-with-xampp-server? –
你可以请看看我的问题bro https://*.com/questions/45173872/virtual-host-cannot-create-with-xampp-server? –