Apache2 virtualhosts

In order to bind a virtualhost to only one ip (if the server has several) add the ip in the VirtualHost tag, to make it listen on all ips – use *
To make the server respond to several names, use the ServerAlias and ServerAlias supports wildcards.

See the examples below for more.

    DocumentRoot /www/subdomain
    ServerName www.sub.domain.tld
    ServerAlias *.sub.domain.tld

<VirtualHost *>
    DocumentRoot /www/domain
    ServerName www.domain.tld