开发者

need help with xampp virtual host

开发者 https://www.devze.com 2023-04-02 06:37 出处:网络
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

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 开发者_StackOverflow社区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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号