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

A public site, on www.mysite.com

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

I've created two different config files for them,



With the default Apache virtualhost configs. No wildcards, the ServerName are www.mysite.com and private.mysite.com 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 private.mysite.com the private part goes well.

But when I visit www.mysite.com, the server goes directly to private.mysite.com.

Apache logs show that those requests to www.mysite.com 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>
     ServerName private.mysite.com
     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>
     ServerName www.mysite.com
     ServerAlias mysite.com
     DocumentRoot /var/www/mysite/
     ErrorLog /var/www/mysite/logs/error.log
     CustomLog /var/www/mysite/logs/access.log combined
  • 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. May 27, 2011 at 15:11
  • Edited, added info in case it is useful...
    – javipas
    May 27, 2011 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, 2011 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. May 28, 2011 at 0:27
  • I'll review my questions and try to apply that criteria. Thanks for the tip Shane :)
    – javipas
    May 28, 2011 at 8:39

2 Answers 2


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>

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 www.mysite.com is not matching for some reason, and so Apache uses private.mysite.com as the default virtual host (as it's the only one present).

  • Info posted. Hope that helps!
    – javipas
    May 27, 2011 at 18:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .