So, I just bought a brand new domain. I set up my dns records with the host (godaddy) but something strange happens on my server.

I've added this to the httpd.conf file:

<VirtualHost *:80>
ServerName www.newdomainname.tld
DocumentRoot /usr/share/roundcube/

But somehow I'm redirected to the root of my server. Then I tried adding this under the entry for the new domain name:

<VirtualHost *:80>
ServerName shop.olddomainname.tld
DocumentRoot /usr/share/roundcube/

And it worked without any problems. What's going on? Am I forgetting anything?


Assuming this is your first additional domain, do you have a NameVirtualHost outside of the VirtualHosts section?

NameVirtualHost *:80 

The setup for multi VirtualHosts is documented nicely at http://httpd.apache.org/docs/2.2/vhosts/examples.html

A good way to figure out what you have configured is to run

/usr/local/apache2/bin/httpd -S 

Which will return all directives currently configured.

  • I had that in the ports.conf file, but not in the httpd.conf file. I also have a few files in sites-enabled/, but don't really know what files get loaded at what time... – skerit Mar 30 '11 at 9:36
  • Okay, you can figure out what the VirtualHost setting are by running httpd -S (added to original answer). – Decado Mar 30 '11 at 9:59

On Ubuntu you should define your virtual hosts in /etc/apache2/sites-available. These get linked to the /etc/apache2/sites-enabled by the a2ensite command.

You may want to examine the existing default site and possibly disable it with the a2dissite command. The first defined site will be treated as the default site by apache.
As your definitions are the same, you may just want one site with a serveralias defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.