Problem with configuring virtual hosts

Some information

  • XAMPP 1.7.1
  • OS tested on vista and xp

Welcome all. I have some problems setting up my virtual hosts. I currently have two sites.

Here is my vhost.conf file:

<VirtualHost *:80>
    ServerAdmin me@site.nl
    DocumentRoot c:/xampp/htdocs/site1/trunk/
    ServerName site1.local
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin me@site.nl
    DocumentRoot c:/xampp/htdocs/site2/trunk/
    ServerName site2.local
</VirtualHost>

      

And of course in my host file

127.0.0.1 site1.local
127.0.0.1 site2.local

      

I restarted apache as well as my browser at different times.

Here's my problem:

http: //site1.local works. But when I go to http: //site2.local , I come to site1.local.

any idea?

+1


a source to share


1 answer


Try

<VirtualHost "site1.local">
    ServerAdmin spam@a1230912##ad#.nl
    DocumentRoot c:/xampp/htdocs/site1/trunk/
    ServerName site1.local
</VirtualHost>

<VirtualHost "site2.local">
    ServerAdmin spam@a1230912##ad#.nl
    DocumentRoot c:/xampp/htdocs/site2/trunk/
    ServerName site2.local
</VirtualHost>

      

You always get site1 because Apache defaults to the first.

change

Uncomment

#NameVirtualHost *

      

to



NameVirtualHost *

      

In your httpd.conf

Mine says (/etc/httpd/conf/httpd.conf)

126 # Listen: Allows you to bind Apache to specific IP addresses and/or
127 # ports, in addition to the default. See also the <VirtualHost>
128 # directive.
129 #
130 # Change this to Listen on specific IP addresses as shown below to 
131 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
132 #
133 Listen 127.0.0.1:80
134 NameVirtualHost 127.0.0.1

      

And my vhost file has

<VirtualHost "www.whatever.com">
        DocumentRoot /var/www/html/whatever/pub
        ErrorLog logs/error_log
        ServerName www.whatever.com
...

      

+2


a source







All Articles