Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

This problem has never occurred in the past (i have tried this many times) but this time,

ALL virtual hosts defined in the virtual-hosts.conf file in the apache installation directory direct the browser to the apache server documentRoot directory.

I am using windows 7 with the latest version of apache.

These are the virtual hosts defined

NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerName dev.a.local
    ServerAlias dev.a.local
    DocumentRoot "D:/wwwroot/a/public"
    ErrorLog "logs/a.log"
    CustomLog "logs/a-access.log" common

    <Directory "D:/wwwroot/a/public">
        Options Indexes FollowSymLinks
        AllowOverride All
    # Controls who can get stuff from this server.
     Order allow,deny
         Allow from all
         DirectoryIndex index.php
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName dev.b.local
    ServerAlias dev.b.local
    DocumentRoot "D:/wwwroot/b/public"
    ErrorLog "logs/b.log"
    CustomLog "logs/b-access.log" common

    <Directory "D:/wwwroot/b/public"s>
        Options Indexes FollowSymLinks
        AllowOverride All
    # Controls who can get stuff from this server.
     Order allow,deny
         Allow from all
         DirectoryIndex index.php
    </Directory>
</VirtualHost>

I have modified the hosts file and added

127.0.0.1 dev.a.local 
127.0.0.1 dev.b.local

When i try to access dev.a.local or dev.b.local i am directed to the documentRoot of apache defined in httpd.conf.

Please help.

share|improve this question
add comment

2 Answers

Verify that the virtual hosts configuration file is not commented out in httpd.conf (as it is by default).

Example (Mac paths)

# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf

to

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
share|improve this answer
add comment

This may be all there is to it, but at the VERY beginning of that config file, put this line:

Listen 80

This tells Apache to actually listen for requests on port 80, and should help it work with the NameVirtualHost directive.

ALSO!!! You have a typo on line 33:

<Directory "D:/wwwroot/b/public"s>

Should the problem persist, post your entire config file and I'll be happy to update my answer.

share|improve this answer
    
Thanks. Directives are taken from a separate conf file. The Listen directive exists in the httpd.conf file. –  andreas May 29 '12 at 22:12
    
Ok, just checking. Non-standard (Linux) installations of Apache always differ day to day, from past experience. Best of luck. Was your issue solved? –  ionFish May 29 '12 at 22:32
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.