Vhost taking only into account the first block <VirtualHost>

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Vhost taking only into account the first block <VirtualHost>

Postby lamando » 11. November 2009 12:59

Hello,

I'm using xampp for many years, and I'm using virtual hosts for all my projects (one domain per project). Everything went smooths with the past versions, but now I'm trying to install the newest 1.7.2 so I can enjoy PHP 5.3, however the vhost won't work as expected!

It seems that the very first <VirtualHost> block defines the default DocumentRoot for all the following blocks!

For example I have:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "G:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\Projects\project1"
    ServerName project1.localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\Projects\project2"
    ServerName project2
</VirtualHost>


All the domains (localhost, project1.localhost and project2) are pointing to "G:\xampp\htdocs".

Now, if I change the order:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "G:\Projects\project1"
    ServerName project1.localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "G:\Projects\project2"
    ServerName project2
</VirtualHost>


This time all the domains are pointing to "G:\Projects\project1", including localhost.

This is really weird since this very same configuration worked very well during the past 2 years so it must be a problem with the new version of XAMPP 1.7.2!

Both httpd-vhosts.conf and httpd.conf are exactly the same (expected the new values) as my previous installation of xampp.

There is no explanation :| I'm trying new settings for 2 days now and I would really appreciate your help!

Thank you.


--------------------
XP Pro x32 SP3 and xampp 1.7.2.
lamando
 
Posts: 7
Joined: 11. November 2009 12:43

Re: Vhost taking only into account the first block <VirtualHost>

Postby Nobbie » 11. November 2009 14:31

You forgot to specify the NameVirtualHost Directive.

See http://httpd.apache.org/docs/2.0/en/vho ... based.html
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Vhost taking only into account the first block <VirtualHost>

Postby lamando » 11. November 2009 19:56

Nobbie wrote:You forgot to specify the NameVirtualHost Directive.

See http://httpd.apache.org/docs/2.0/en/vho ... based.html

OMG the line
Code: Select all
NameVirtualHost *:80
was commented in the httpd-vhosts.conf of the new installation and I missed that!

Thank you soooooo much!!!!! It works!!!!
lamando
 
Posts: 7
Joined: 11. November 2009 12:43


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 131 guests