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 have got a strange problem.

I have two domains: and, which need to point to the same directory on my server. The VHost for works perfectly. However, will not work.

When I re-start apache I see no errors. When I enter the domain, it is reaching the correct server but showing me the index file in /var/www, instead of re-directing to /var/www/html/

Is there an error with my code? It is EXACTLY the same as what appears on the configuration for, so I am very confused as to why it is not working properly.

Sites Available:

<VirtualHost *:80>
DocumentRoot /var/www/html/
ServerAlias *


<VirtualHost *:80>
ServerName *
DocumentRoot "/var/www/html/"
share|improve this question

You should be able to do this with a single vhost entry as long as the content you want displayed on both URL's is in the same folder on the server.

<VirtualHost *:80>
ServerAlias * *
DocumentRoot /var/www/html/

You may also be getting betrayed by a default vhost if you have setup your new ones in a seperate file.

If your running Ubuntu (Or some other distro's) you can use 'apache2ctl -D DUMP_VHOSTS' from the command line to show what ServerNames are being accepted and what config file:line they are in.

Note - this does not list address added on ServerAlias lines

share|improve this answer

I don't think you should be using wildcards in your second ServerName directive (in Apache.conf), try replacing it with www for the moment, while leaving the wildcard aliases in Sites Available, if you have more than one subdomain the server will respond to.

share|improve this answer
Ok, I just tried that but no luck. What logs should I be looking at for any potential errors? – Bob Flemming May 14 '13 at 9:57
Can you change one more thing? I think the ServerAlias in Sites Available should probably be *, you may not see errors, as it isn't wrong, just not right for what you want.. – NickW May 14 '13 at 10:06
Ok I have got it working on I was having an issue with, but I have changed the mx record of to point at the new server and the vHost seems to work. However, is still not working so I guess its a subdomain issue? - Apologies for not mentioning that in my question – Bob Flemming May 14 '13 at 10:22
It may be a DNS issue, you need to make sure that test is either a CNAME or an A record, and that record now points to the new server. – NickW May 14 '13 at 10:26
First try and add the ServerAlias directive to apache.conf also, possibly both with just, just to ensure the Alias matches exactly.. – NickW May 14 '13 at 10:34

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.