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 want to enable the access to my site without the "www." prefix. I tried to insert this in my /etc/apache2/sites-available file:

<VirtualHost *:80>

        DocumentRoot /var/www/mydomain/

        ... (lot's of other configs)

But this isn't working... :(

When I dig the domains I get different IP results: - -

share|improve this question
You haven't fixed your DNS records yet? – gravyface Apr 15 '10 at 20:58
I've edited my answer with tips on how to change your DNS records. – gravyface Apr 15 '10 at 21:12
Do you have those IPs on network interfaces? can you paste the output /sbin/ip address show ? – Mircea Vutcovici Apr 15 '10 at 21:35
up vote 14 down vote accepted

serverAlias needs to be title caps (ServerAlias) and you need to add whatever sites you want this virtual host to respond to on this line, separated by a space like so:


Make sure that you have a A host record for (or a CNAME) so that it can be resolved properly. Also I'm not sure if you've ran a2ensite yet, you didn't say whether it was working at all or not.

EDIT Apparently you need step-by-step instructions on how to change your DNS records. However, unless you're going to post your actual domain (and we can look up your NS records), we have no idea who controls your DNS or how to change them.

To figure this out without posting your actual domain, you can do:

dig ns

This should return some records like, etc.

Does "" ring a bell? If not, who registered this domain? Can you contact them? They likely have access to the nameservers or know someone who has access to the nameservers. You can also look up the WHOIS records and you may see an email address there that's familiar to you.

share|improve this answer
And how do I create this A record or CNAME? – TiuTalk Apr 12 '10 at 17:32
Through your registrar or DNS provider/server where you setup in the first place. – gravyface Apr 12 '10 at 17:37
@gravyface - This is not made locally (I mean, in the server.. it's a dedicated server)? – TiuTalk Apr 12 '10 at 17:39
The A record and CNAME refer to DNS entries for the given domain ( in your question). How to create them depends upon which DNS server the site is using (e.g. named/bind, PowerDNS, djbdns, dbndns). – mctylr Apr 12 '10 at 17:45
No, this would be wrong in your nameservers. – gravyface Apr 12 '10 at 21:40

This is definitely a DNS problem; you should of course configure your web server as appropriate for your needs, but if "" doesn't point to it, you're not going anywhere :-)

share|improve this answer

Your Apache config looks ok to me. The DNS record for should point at the same IP address as the www. one, unless Apache is also listening on this IP address - but if it were then your site would probably work.

You need to check your DNS service to figure out where the record for the www. free record is being defined.

share|improve this answer

if your problem seems to be with name resolution, then I would agree you would a CNAME record for the domain as an alias. Your domain may already have a corresponding A record for it, this may be why the domain has been mapped to a different IP. Add the same A record for it as the alias, or map a CNAME string to it, A record incurs less overhead, b/c of no CNAME chain

share|improve this answer

My guess is that you dont need the "ServerAlias" string at all. You only need the "ServerAlias"

Then, in you DNS servers domain management screen (which I presume you have) you need to set up the DNS pointer records correctly.

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.