Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a Ubuntu 10.04 LTS machine with a classical LAMP installed. I've created two sites:

A public site, on

A "private" site that for the moment is open, on

I've created two different config files for them,



With the default Apache virtualhost configs. No wildcards, the ServerName are and respectively, and I haven't used wildcards.

And of course there symlinks to those on /sites-enabled. Each of the sites has its own directory,



The public site is a WordPress blog. The private site is a webapp with several php files.

Everything should fine, and I've checked everything several times, but something weird happens. When I visit the private part goes well.

But when I visit, the server goes directly to

Apache logs show that those requests to aren't even logged on

/var/www/mysite/logs/access.log (or error.log)

They go instead to


So EVERY request goes to the subdomain. Any ideas to correct this behaviour?

************** Update *******************

More info:

ls -l /etc/apache2/sites-available/

-rw-r--r-- 1 root root  859 2011-05-27 13:33 private-mysite
-rw-r--r-- 1 root root  948 2010-11-18 22:16 default
-rw-r--r-- 1 root root 7467 2010-11-18 22:16 default-ssl
-rw-r--r-- 1 root root  264 2011-05-27 14:22 mysite

/etc/apache2/sites-available/private-mysite contents:

<VirtualHost x.x.x.x:80>
     DocumentRoot /var/www/private-mysite/html/
     ErrorLog /var/www/private-mysite/logs/error.log
     CustomLog /var/www/private-mysite/logs/access.log combined

/etc/apache2/sites-available/mysite contents:

<VirtualHost x.x.x.x:80>
     DocumentRoot /var/www/mysite/
     ErrorLog /var/www/mysite/logs/error.log
     CustomLog /var/www/mysite/logs/access.log combined
share|improve this question
Can you post configs? My money's on the VirtualHost address declaration not matching the NameVirtualHost block. And it may be a good idea to accept some answers to your older questions. – Shane Madden May 27 '11 at 15:11
Edited, added info in case it is useful... – javipas May 27 '11 at 18:38
Thanks for your answer, Shane, it was the solution!. I've reviewed my older questions, but there were not very valid answers to them. Should I accept answers even if they don't solve the problem?? – javipas May 27 '11 at 19:27
No, but if they lead you in the right direction, then they may be good enough to accept. Another option is if your figure out a solution yourself, you can put your own answer in and accept it; this is good because future visitors may have the same issue and find your question in a search. – Shane Madden May 28 '11 at 0:27
I'll review my questions and try to apply that criteria. Thanks for the tip Shane :) – javipas May 28 '11 at 8:39
up vote 1 down vote accepted

The VirtualHost host definition blocks need to match the NameVirtualHost directive. It's probably in /etc/apache2/ports.conf, and is probably set to *:80.

To resolve, either change your NameVirtualHost:

NameVirtualHost x.x.x.x:80

or change your VirtualHost definitions:

<VirtualHost *:80>
share|improve this answer
That was EXACTLY the problem. Thank you so much!! – javipas May 27 '11 at 19:24

Please post the configuration files themselves and ls -l /etc/apache/sites-available. Do you see any errors or warnings whatsoever when restarting Apache?

This may happen because is not matching for some reason, and so Apache uses as the default virtual host (as it's the only one present).

share|improve this answer
Info posted. Hope that helps! – javipas May 27 '11 at 18:39

Your Answer


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.