0

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.

2 Answers 2

1

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.

2
  • Thanks. Directives are taken from a separate conf file. The Listen directive exists in the httpd.conf file.
    – Andreas
    Commented May 29, 2012 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
    Commented May 29, 2012 at 22:32
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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