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

I have the following folder structure on my Apache



I have defined a virtual host for each.

So if I type in in my browser I get to the site. And the same for

But now my question! If I type in the server address or the server host name I get to the ../var/www directory but I want that the user will be redirected to the site!

Do I have to create a new virtual host for this problem or is it also possible only to add a .htaccess Rule?!


share|improve this question

2 Answers 2

You don't mention how you configured your virtual hosts, but I guess that you've done it following the "traditional" Debian-way - by creating files in /etc/apache/sites-available/ and then using a2ensite to enable the virtual host.

If so, you may edit your /etc/apache/sites-available/default file and put the virtual host you want to be the default one in it. For example:

<VirtualHost _default_:80>
  DocumentRoot /var/www/

More information about the _default_ keyword.

EDIT : If you're using name-based virtual hosts, just make sure that the configuration for the vhost is loaded first - this way it will be the default catch-all address.

share|improve this answer
_default_ doesn't do anything when using name-based virtual hosts, just IP-based. @Matthias, which method are you using? – Shane Madden Jun 30 '12 at 19:37
Yes, indeed. That was a bad assumption from me. Edited my answer above. – Vladimir Blaskov Jun 30 '12 at 20:30

You have to user a ServerName and a ServerAlias in your vhost configuration file

<VirtualHost *:80>


Otherwise, if you want to have a default website for the unspecified vhost, you have to create an vhost for that. You can check that with the command:

apache2ctl -S
share|improve this answer
Javier, I'm pretty sure he's asking about a default catch-all address, so I think the _defaut_ keyword would be more appropriate in this case. – Vladimir Blaskov Jun 30 '12 at 8:39

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.