Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have a web server with quite a few domains on it. I am looking for an easy way to point specific sub-domains (webmail, phpmyadmin) on any TLD hosted on this server to a folder with the relevant systems using an Apache vhost.

So regardless of what domain, as long as someone enters phpmyadmin as a subdomain it should load the applicable folder.

I have a method to add a cname automatically for each DNS zone, but I'm struggling with Apache.

share|improve this question
up vote 2 down vote accepted

A wildcard ServerAlias should do the trick..

<VirtualHost *:80>
    ServerName phpmyadmin-handler
    ServerAlias phpmyadmin.*
    # any and all settings needed for phpmyadmin to function..
    DocumentRoot /path/to/phpmyadmin
    <Directory /path/to/phpmyadmin>
        Order allow,deny
        Allow from all
share|improve this answer
+1 for the obvious yet brilliant solution – Mathias R. Jessen Jul 21 '12 at 22:57

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.