Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 setup a server with Ubuntu 10.04 server edition. It's works for a long time with a single domain name. Now i want to add another domain wich will pointed to a new directory.

I tried to change my Apache2 configuration but it does not seems to work properly.

Here is my /etc/apache2/sites-available/default

<VirtualHost *:80>
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


<VirtualHost *:80>
DocumentRoot /var/www/mydomain

here is my /etc/hosts localhost

**.***.133.29   sd-***.****.fr sd-****

 # The following lines are desirable for IPv6 capable hosts 
 ::1     localhost ip6-localhost ip6-loopback
 ****::0 ip6-localnet
 ****: :0 ip6-mcastprefix
 ****::1 ip6-allnodes
 ****::2 ip6-allrouters
 ****::3 ip6-allhosts

With this configuration when i try to access to mydomain it redirect to the /var/www/ content. Do you have any idea to redirect to the right folder ?

share|improve this question

If you look at the following example taken from apache doc, it seems you are missing ServerName line from the first virtual host. Try to make your configuration similar to this (of course, you can keep the other directives like <directory>).

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain

Don't forget to setup the right DNS entries or at least modify your hosts file to resolve both domains to the correct IP address.

share|improve this answer
My first Virtualhost don't have any name, it show some content after redirection... Just added my /etc/hosts – x_vi_r Sep 3 '12 at 14:36

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.