Setting up virtual hosts in apache ver 2.4.9 (WAMP, Windows 2012)

Hello, I have a wamp server running and my conf/extra/httpd-vhosts.conf configuration is as follows;

On my httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

On my c:\xampp\apache\conf\extra\httpd-vhost.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80

# for localhost to work properly
<VirtualHost *:80>
    DocumentRoot "c:\wamp\www"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory  "c:/wamp/www">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "c:\wamp\www\folder01"
    ServerName demo.re-web.com
    ServerAlias demo.re-web.com
    ErrorLog "logs/mysite-error.log"
    CustomLog "logs/mysite-access.log" common
    <Directory  "c:\wamp\www\dds">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "c:\wamp\www\folder02"
    ServerName stage1.re-web.com
    ServerAlias stage1.re-web.com
    ErrorLog "logs/mysite-error.log"
    CustomLog "logs/mysite-access.log" common
    <Directory  "c:\wamp\www\dds">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>

Open in new window


my hosts file is:
127.0.0.1       localhost
127.0.0.1       demo.re-web.com
127.0.0.1       stage.re-web.com
127.0.0.1       stage1.re-web.com
::1             localhost
::1             stage.re-web.com
::1             demo.re-web.com
::1             stage1.re-web.com

Open in new window


The issue I am having is that when is use stage1.re-web.com (or any of the other virtual sites ) the  site that always comes up is my localhost content and not the folder that I have pointed my virtual site to (folder 01 / folder 02). How can I correct this issue?

Thanks,
A
aej1973Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve BinkCommented:
Apache matches virtual hosts in a first-match process.  In other words, it selects the first virtual host definition that matches IP and host name.  

Try disabling the default virtual host configuration found in your Apache installation, or having your definitions included before the default.
0
aej1973Author Commented:
When you say 'default Virtual host' do you mean the following lines?
<VirtualHost *:80>
    DocumentRoot "c:\wamp\www"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory  "c:/wamp/www">
        AllowOverride All
        Options Indexes FollowSymLinks
        Require local
    </Directory>
</VirtualHost>

Open in new window

0
Steve BinkCommented:
That could be it.  You can check for sure by opening a command prompt, changing directories into your apache2\bin, and running:
httpd -S

Open in new window

The output of that command will list all the defined virtual hosts and their files, though not necessarily in order.  You can go through each of those to discover in what order they are being included, and modify that order if necessary.

Also, make sure you have a "NameVirtualHost *:80" somewhere in your config.
0
InsoftserviceCommented:
Just change  ##NameVirtualHost *:80 to NameVirtualHost *:80
restart your service

And your problem is solved
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aej1973Author Commented:
Thank you all...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.