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

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 an Ubuntu server with apache2, where I host a small community. The domain for this is (as an example) domain.tld. I Try to add a simple ServerAlias that allow users to append a www-prefix, like this: www.domain.tld

I have read all documentation I could find, but can not get it to work.

Here is the default file in Apache (slightly modified from the original default):

<VirtualHost *:80>
    ServerAdmin admin@localhost
    ServerName domain.tld
    ServerAlias www.domain.tld

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/>
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from ::1/128


Any help with this problem is highly appreciated!

share|improve this question
I've never really thought about it before, but don't you have to have the ServerName set in order for ServerAlias to work? I.E. ServerName domain.tld and ServerAlias www.domain.tld – Safado Dec 12 '12 at 21:47
^-- Safado is correct – thinice Dec 12 '12 at 21:49
Sorry, My bad: It was in the file, but somehow it went gone. It is still not working, regardless if ServerName is there or not. – TheLugal Dec 12 '12 at 21:52
Do you have DNS set up for www.domain.tld? What happens when it "fails"? – Safado Dec 12 '12 at 21:55
Back to a previous question, what happens when it "fails"? What does your browser say? (can't resolve host, 403 forbidden, cannot find server, etc.. ) – Safado Dec 13 '12 at 0:01
up vote 0 down vote accepted

Try setting it like this ....

ServerName   domain.tld
ServerAlias  www.domain.tld

ServerName being the "main" name and ServerAlias being any additional names you want the vhost to respond to.

share|improve this answer
As already stated, it is there, it just happens to be left out at one point. I've added it back and it still don't work. (And restarted apache.) I've updated the question. – TheLugal Dec 12 '12 at 21:55

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.