Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an Apache server with multiple sites using their own domains. For one of those sites I wish to have wildcard subdomains.

I have set up the domain records for * and it works just fine.

With this I can configure any subdomain (e.g. to point to any site, as long as I specify the subdomain name.

The wildcard domain though (* ends up on the site that is configured in /etc/apache2/sites-available/default instead of the site that has ServerName *

What did I do wrong?


<VirtualHost *:80>
    ServerName *

    DocumentRoot /var/www/example
    <Directory /var/www/example>
        AllowOverride all
        Options -MultiViews
        Allow from all


<VirtualHost *:80>

    DocumentRoot /var/www/default/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    <Directory /var/www/default/>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try switching the ServerName / ServerAlias-directives like this:

ServerAlias *

As far as I know, wildcards only work with the ServerAlias directive.

share|improve this answer
Thanks, it was that easy :) – Christoffer Oct 29 '11 at 12:12

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.