MauricioCarnieletto
MauricioCarnieletto

Reputation: 60

Multiples vHosts with XAMPP 1.7.3

I'm trying to configure multiple vhosts on a machine on my network , however, no matter what I use to access servername , the apacche always directs to the first host.

Here it's my vHosts file

<VirtualHost eurekahom:7777>
    DocumentRoot "d:\vhosts\eurekahom\controller/"
    ServerName eurekahom

 #   RewriteEngine On
 #   RewriteOptions Inherit

    <Directory />
        AllowOverride All    
    </Directory> 

    php_value include_path ".;d:\vhosts\eurekahom\controller\includes/"
</VirtualHost>


<VirtualHost eurekades:7777>
    DocumentRoot "d:\vhosts\eurekades\controller/"
    ServerName eurekades

    <Directory />
        AllowOverride All    
    </Directory>

    php_value include_path ".;d:\vhosts\eurekades\controller\includes/"
</VirtualHost>

<VirtualHost mauricio:7777>
    DocumentRoot "d:\htdocs\mauricio" 
    #\controller/"
    ServerName mauricio

 #   RewriteEngine On
 #   RewriteOptions Inherit

    <Directory />
        AllowOverride All    
    </Directory> 

    php_value include_path ".;d:\htdocs\mauricio"
</VirtualHost>

Did anyone know what's happend?

Upvotes: 0

Views: 508

Answers (2)

Thiago Fassina
Thiago Fassina

Reputation: 266

I believe for virtual hosts there are IP-based matching and server name matching. So whatever you type here: <VirtualHost ________:7777> should be an IP address. Since you don't want to match by IP, you can just leave a *:7777.

So yes, all your statements will start with <VirtualHost *:7777>. When a request comes for that 7777 port, Apache will then try to match by server name, and then the ServerName parameter will be considered.

There might be more issues with the <Directory> statement too, but I believe that is not what was causing Apache to always use the first VirtualHost all the time.

The following link is very useful, as it helped me when I had a very similar problem: https://wiki.apache.org/httpd/CommonMisconfigurations

Upvotes: 1

oomlaut
oomlaut

Reputation: 773

I usually don't specify the host name in the VirtualDirectory element, instead leaving it at *:7777

Also, for directories outside my htdocs folder, I use additional Directory options:

<Directory "C:\Projects\spacelysprockets">
    Options All
    AllowOverride All
    Require all granted
</Directory>

Upvotes: 0

Related Questions