Q:

It is known that apache resolves foo.com even if as named virtual host only beta.foo.com exists?

The only virtual hosts i have are:
<VirtualHost *:80>
DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>
    # etc...
</VirtualHost>

and
<VirtualHost xx.xx.xx.xx:80>

DocumentRoot /var/www/vhosts/beta.foo.com/htdocs
ServerName beta.foo.com

<Directory /var/www/vhosts/www.foo.com/htdocs/>
    Options All -MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

ErrorLog  /var/www/vhosts/www.foo.com/logs/error.log
LogLevel debug  
CustomLog /var/www/vhosts/www.foo.com/logs/access.log combined

</VirtualHost>

beta.foo.com is perfectly reachable, and that's the expected behaviour.
But when i try to get www.foo.com, it resolves to beta.foo.com and not to the default configuration.
Is this an Apache rule?
Is there a way to avoid this?
The only way is to set a virtual host with ServerName www.foo.com?

A:

The documentation explains how the virtual host is chosen. Basically, your beta.foo.com host is chosen because it has a specific IP address, whereas the default host uses a wildcard. Either change your beta.foo.com block to also use a wildcard, or change your default host to use the specific IP.

