There are number of situations when you want to create 1 common subdomain for all hosted domains on your server. For example when you want all projects/domains to have webmail access, like so mail.domain1.com, mail.domain2.com etc.

You could create virtualhost and manually add subdomains in ServerAlias, but that’s too much trouble isn’t it?

Wildcard to the rescue…

Surprisingly, documentation about the use of wildcard in apache2 ServerName and ServerAlias are nonexistent. So I had to go through several tries to get it right.

My initial hunch was to go with ServerName mail.*, apache didn’t complain but mail subdomain didn’t work.

Anyways this is a working virtualhost:

Leave a Reply

Your email address will not be published. Required fields are marked *