Virtual Host problem; resolving to same domain

Posted on 2006-10-24
Last Modified: 2010-03-04
Hello!  I'm attempting to setup my webserver to host 3 different websites, each of which have a seperate domain name and share a common IP hosted off of one machine.  I'm new to using Virtual Hosts -- I'm having an issue where *all* domains are resolving to the first domain rather than to the intended domain.  

my httpd.conf reads:

NameVirtualHost *:80

  DocumentRoot  /var/www/html/done

  DocumentRoot /var/www/html/dtwo

  DocumentRoot /var/www/html/dthree


I would be grateful if you can shed some light on what I'm missing or doing wrong!  Thnx!
Question by:minnirok
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Author Comment

ID: 17801019
I.E. the problem is that accessing or is bringing up the files for which are stored localy in /var/www/html/done
LVL 43

Expert Comment

ID: 17801476
Looks fine for me, but my config have something reverted comparing to Yours, try it...

Listen 80
LVL 15

Expert Comment

ID: 17803696
I agree with ravenpl - I'd specify the IP address in the NameVirtualHost command if it isn't working.  

The Apache web server will deliver the first entry as a 'default' if nothing matches.

Is it possible that your or actually point to a different IP address which points to the same server?
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Author Comment

ID: 17805657
Thanks guys. It looks like the problem occurs if I have the NameVirtualHost set to *:80

With the *:80 setting, all my traffic gets routed through to  I don't yet understand why this occurs.  Setting the virtual host to *all* IP addresses on port 80 (ie *:80) really shouldn't be messing up the individual virtualhosts -- since each virtualhost is set to they should still be able to resolve to the proper domain.  But, yeah, somehow under this setting the first domain supercedes all others...  Am I missing something?

Also, possibly relevant, ServerName is set to

Thanks ravenpl, changing my settings to listen only based on port and namevirtualhost to a specific IP does resolve the problem.  In the interest of learning, I'm very curious to learn why the initial settings don't work!  Any theories?
LVL 43

Accepted Solution

ravenpl earned 100 total points
ID: 17805817
In fact says
Note that the argument to the <VirtualHost> directive must exactly match the argument to the NameVirtualHost directive.
So I suppose the following could work
NameVirtualHost *:80
<VirtualHost *:80> //not the IP!, OR
<VirtualHost _default_:80>

But then, the same link says to not use it this way
Note, that the "main server" and any _default_ servers will never be served for a request to a NameVirtualHost IP address (unless for some reason you specify NameVirtualHost but then don't define any VirtualHosts for that address).


Author Comment

ID: 17805907
Great!  I had missed that note about how the virtualhost and namevirtual host have to match :)

Thanks, ravenpl!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL ( and MongoDB (…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question