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

Possible Duplicate:
to www or not to www

Consider a website at

When the URL is entered manually into Firefox's address bar as , the browser automatically redirects to

Using Internet Explorer, the browser redirects to a default search engine with the search term for

Sites like or all are automatically changed to redirect to their www address.

Is there a setting on the web server to change this behaviour?

Any other issues coming into play here?

share|improve this question

marked as duplicate by Chris S May 27 '12 at 2:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

One should note that Firefox is rewriting your "" into "" because "" does not resolve. IE, instead, doesn't, and points you to the search engine. To fix, "" must resolve (as pointed out below). – Mei Jul 9 '09 at 16:03

Generally, you set up your webserver so that one domain is canonical, and any aliases you want are redirected to it. If specify which webserver, someone will be along shortly to tell you how :)

With Apache, you might do something like this:

<VirtualHost *>
    #our canonical name

    #other domains we want to respond to

    RewriteEngine on

    #if host is specified and not our canonical one, redirect
    RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
    RewriteCond %{HTTP_HOST}   !^$
    RewriteRule ^/(.*)$1 [L,R=permanent]



Note that you must still define A or CNAME records for all the aliased domains.

share|improve this answer
You also need to ensure both addresses are setup as A records or CNAMEs in DNS. – Brent Jul 9 '09 at 15:59

I'd recommend setting up one of the two names to be the canonical and unique way to access your web site and the other to redirect to it. Don't use CNAME, or JavaScript redirection. Use HTTP redirection.

Personally I redirect from to because I'm against www. The reason is quite simple: the fact that you are using a web browser and http already says that you are trying to access the web site at that location, no need to add more redundant information. Also, may be HR's web site, does that mean then that you have a www department at your company? and if not, then it should be, which looks rather bad.

share|improve this answer
exactly my thoughts. see – Javier Jul 9 '09 at 16:24
You're still going to need to be able to send one from the other. Kind of hard to do that if you can't get to the one. – Kevin M Jul 9 '09 at 18:02
This is all fine and good, but cookies set at the TLD are leaked to the subdomains. If it wasn't for this cookie behavior I would totally be on board with the NO WWW. – Clint Pachl Jan 24 '11 at 23:48
@Javier seems to disagree with you there – Pacerier Sep 14 '11 at 6:20
@Clint do you mean to say that if the TLD domain starts with www, the cookies set at the TLD wouldn't be leaked to the subdomains ? – Pacerier Sep 14 '11 at 6:21

Look at the url above. doesn't go to They are two separate dns entries. Take a look at your DNS host configuration and try to add an A record for and that should fix the problem.

share|improve this answer

As already mentioned, you're going to have two separate DNS records. If this is desirable (e.g. you don't just want, then you want to have one name to be the canonical name. This is important for things like cookies to work as you intend for your end users.

I don't know what web server you're using, but if it's Apache then you'll use URL rewriting as described at the following page:

Search the document for "canonical hostnames".

share|improve this answer

See the Stack Overflow question on the issue: Should I default my website to or not?

share|improve this answer

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