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

On my Vserver Id like to configure a subdomain. So I have the following entries in my apache vhost config. I want to have my site to run as own site, so that pages and files have the domain e.g. or

<VirtualHost *:80>
  DocumentRoot /var/www/app1

<VirtualHost *:80>
  DocumentRoot /var/www/example

<VirtualHost *:80>
  DocumentRoot /var/www/wildcard
  ServerAlias *

But WHY do I need a DNS like this additionally? Dont I set this already in my vhost config?

Host        Type    Destination
app1        A       78.xx.xx.xx (my IP)
*           A       78.xx.xx.xx

Or do I need to point the destination to a directory like this: Thx for advise!

share|improve this question

If you have a wildcard record pointing to the IP of your subdomain you won't need the more specific app1 A record, the wildcard will take care of that. The user's browser sends:


When it makes a request for that domain, that's how Apache knows which domain the client wants. The wildcard record will tell the browser to send that request to your server.

share|improve this answer

Hmm, I think that perhaps part of the problem is the usage of '=' in setting DocumentRoot. Unless that is some alternative syntax that is rarely used the apache documentation appears to recommend using something like 'DocumentRoot /foo/bar' where /foo/bar is the document root you want. See . With regards to your dns issue, the user's browser will send the host header, which if you have the NameVirtualHosts directive set prooerly, will cause the VirtualHost directive with the matching ServerName or ServerAlias to be used. You can configure your DNS server with either a wildcard '*' entry or specific entries or both - the browser will still send the appropriate hosts header.

share|improve this answer
yes the = is a syntax error :) – DannyRe Feb 7 '12 at 10:56
It's all good, mate. Apache config directives do have some interesting syntax. – Justin Lynn Feb 7 '12 at 10:58

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.