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 think I hate Apache now, but on with the issue. It might be a configuration error on my end or just my inability to see what's right in front of me, but I'm trying to configure a sub-domain in Apache and no matter what, it always redirects the sub-domain to the web root of the main domain. My configuration is posted below (and yes, the domain name information was purposefully modified):

<VirtualHost *>
DocumentRoot /var/www/root/
<Directory /var/www/root/>
allow from all
Options +Indexes
<Directory /usr/share/squirrelmail>
Options Indexes FollowSymLinks
<IfModule mod_php5.c>
php_flag register_globals off
<IfModule mod_dir.c>
DirectoryIndex index.php

# access to configtest is limited by default to prevent information leak
<Files configtest.php>
order deny,allow
deny from all
allow from

# users will prefer a simple URL like
<VirtualHost *>
DocumentRoot /usr/share/squirrelmail/
share|improve this question
up vote 2 down vote accepted

You need to enable name-based virtual hosts with NameVirtualHost *. Also, I don't know if this matters, but why is the squirrelmail document root defined outside of its VirtualHost container?

share|improve this answer
It's a package installed from APT, so it wasn't installed inside of the container, and the Naming did fix the issue. – Nik May 29 '10 at 23:55

First: you should indent your configs so they are easier to read. Helps you spot some kinds of errors, too.

I don't really think that this is causing the error, but it's worth a try ;) docs say: The DocumentRoot should be specified without a trailing slash.

I cannot see an error in your virtual host config, and you say it redirects to the default domain, so I don't think the error is on apache's side. Maybe the error is from the index.php you specified – have you set some default host or something in the squirrelmail config so that it redirects? Try to replace the index.php by some file that just prints something and check if that works.

share|improve this answer

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.