Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a problem with VirtualHosts which Apache 2.4.

If I navigate to ty1.dev, I get the site for af2.dev instead

If this was Apache 2.2, all I would need to add is NameVirtualHost *:80 but is ignored in 2.4.

error.log does not report any problems

What have I missed?

# httpd-vhosts.conf
<VirtualHost *:80>
    ServerName af2.dev
    ServerAlias af2.dev
    ServerAdmin user@host.dev
    DocumentRoot "c:/Users/Adam.Adam-PC/Sites/af2/web"
    <Directory c:/Users/Adam.Adam-PC/Sites/af2/web>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName ty1.dev
    ServerAlias ty1.dev
    ServerAdmin user@host.dev
    DocumentRoot "c:/Users/Adam.Adam-PC/Sites/ty1"
    <Directory c:/Users/Adam.Adam-PC/Sites/ty1>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>

</VirtualHost>
share|improve this question
    
What do you get from c:\path\to\apache.exe -S? –  Shane Madden May 31 '12 at 4:52
add comment

1 Answer 1

up vote 1 down vote accepted

try putting a specific ip and port in your listen statement as well as your virtualhost blocks. So put:

listen 127.0.0.1:80

and in each of your virtualhost:

<virtualhost 127.0.0.1:80>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.