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 currently have Apache2 configured to host wildcarded subdomains of the form *.domains.tld, where the * is unique for each client we have.

Each client has an 'admin' page that they can log into, currently at client.domain.tld/admin, that we would like to move to serve from admin.client.domain.tld.

Is it possible to serve a sub-domain to a wildcarded sub-domain? I can't seem to find anything related to this.


share|improve this question
up vote 2 down vote accepted

You can do this with ServerAlias, as it supports wildcards.

<VirtualHost *:80>
    ServerAlias admin.*
    DocumentRoot /path/to/adminsite
    UseCanonicalName Off

This is assuming that they all share the same admin code base, and site-specific options are generated based on their login credentials.

share|improve this answer
Correct, thanks! – Paul Mennega Jan 10 '13 at 22:59
right, but this is only half the story isnt it? What i want to know, is when doing it this way, i.e. when the asterisk isnt first, like the OP was looking for, which is what im doing, do i still use %1 to access the var? and Do i have to use ServerName, or can i leave that part out like i do on all other virtualhost entries unless needed because all this stuff is already defined in the default conf. Someting is causing problems for me, ServerAlias dev.*.ld.pvt VirtualDocumentRoot "/home/username/sites/%1" but i dont know what. – Brian Thomas Apr 28 '15 at 6:40
Brian, you are wanting a different docroot per wildcard domain? i.e: points to /home/username/sites/google? – David Houde Apr 28 '15 at 12:22

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.