0

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>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

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

    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 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

Any help with this problem is highly appreciated!

TheLugal
  • 3
  • 2
  • 1
    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
  • 1
    Do you have DNS set up for www.domain.tld? What happens when it "fails"? – Safado Dec 12 '12 at 21:55
  • To be honest I don't think so. As far as I know my host takes care of that bit. I've read lot of "hints" about DNS, but haven't found any "hands on" information about it. It is noted in /etc/hosts, if that helps... – TheLugal Dec 12 '12 at 22:01
  • Oh, well DNS is what makes the Internet work. If you have a linux or mac box, do `dig +short www.domain.tld` and see if it returns your IP address – Safado Dec 12 '12 at 22:12
  • It does return my IP address. – TheLugal Dec 12 '12 at 23:59
  • 2
    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 00:01
  • What _is_ the problem? – Michael Hampton Dec 13 '12 at 00:18

1 Answers1

0

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.

Safado
  • 4,786
  • 7
  • 37
  • 54
  • 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