需要 xampp 虚拟主机帮助
我正在使用 XAMPP、Apache 2.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 的测试站点,所以这很好。但是如果我输入 localhost,它也会转到测试站点。如果我移动到测试站点之前,那么 localhost 会转到 localhost good,并且 www.domain.tld 也会转到 localhost。我尝试了 localhost 的不同设置,例如
<VirtualHost *>
<VirtualHost localhost:80>
从 domain.tld 中删除 *.domain.tld 但没有任何效果。我错过了一些明显的东西吗?
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>
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>
and removing *.domain.tld from domain.tld but nothing works. Am I missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己的答案:以下代码解决了问题
My own answer: The following code fixed the problem
请将您的服务器名称从虚拟主机更改为本地 IP 地址,例如 127.0.0.2。
ServerName domain.tld 是使用“domain.com”的示例,其中 .tld 被替换为您的域的 .com。
please change your ServerName from virtualhost to a local IP address such as 127.0.0.2.
ServerName domain.tld is an example of using "domain.com" where .tld is replaced by .com for your domain.