84

What are the pros and cons of having http://www.example.com/ vs http://example.com/?

For example a problem I'm aware of is that if I use a domain without www I can't set a cookie for the current subdomain only (since there is no subdomain), and the cookies I set will be sent to all subdomains.

1
  • 1
    @John Conde: I think the edit you approved made the question worse.. "My question is fairly simple to complex and want to know the in's and outs of www vs non-www." was edited in, which is broken english and doesn't make sense in any case. Commented Feb 15, 2013 at 15:20

8 Answers 8

69

Keep in mind though that using www.example.com lets you to set Cookies only on the main site. Using example.com will only allow you to set cookies on *.example.com which includes static.example.com. So every request for any subdomain will include the cookies which slows down the transfer a bit. Using www.example.com will allow you to decide for what part you want to set cookies.

6
  • 8
    This is one of the big reasons why large websites setup completely separate domains for static content (such as sstatic.net for Stack Overflow) so that they have cookie-free domains. More info here: developer.yahoo.com/performance/rules.html#cookie_free
    – Greg Bray
    Commented Jul 10, 2010 at 21:23
  • 11
    yes this is the biggest downside of the "no-www" movement, by far. It is definitely annoying. Commented Jul 11, 2010 at 3:32
  • @Jeff: True to an extent, but it can be more beneficial to host static content on a different domain anyway, to increase parallelization. Commented Jul 12, 2010 at 21:04
  • 3
    @DisgruntledGoat: the parallelization is increased also using subdomains! developer.yahoo.com/performance/rules.html#split Commented Aug 27, 2010 at 15:19
  • 2
    This answer is becoming obsolete now that RFC 6265 is more widely implemented. (It did not exist at the time this answer was written, though.) Commented Apr 16, 2013 at 3:18
28

If you are going to use www.example.com, you should make example.com a permanent re-direct to www.example.com.

The www sub domain, in some cases, is actually a completely different server than the parent TLD. While most search engines are smart enough to figure that out, its still good practice to place the re-direct.

I'm the complete reverse of that, www.example.com is a permanent redirect to example.com, because I prefer using the shorter canonical URL. It also make sense to me that I can expect a HTTP request to example.com will yield a web page, or a redirect to whatever subdomain is dealing with HTTP requests.

Additionally, you want people linking to your site using the canonical URL, which is the one they pick out of their browser toolbar. The re-direct on the one that is NOT your canonical URL helps ensure consistency in that regard.

1
  • meaning that one should use example.com not www.example.com?
    – Adelin
    Commented Feb 22, 2022 at 18:50
23

Including the www subdomain seems to boil down to two conditions:

  1. Cookies - Will setting cookies at *.example.com cause me grief (incur more traffic) because the cookies will be sent with every request, regardless of subdomain. In this case I would opt to use the www since it gives me the choice of setting cookies at *.example.com if I need it (ex. authenticated user cookie), or www.example.com to reduce traffic to my other subdomains.

  2. Aesthetic - Do I care a lot about how the domain looks? If I really hate the www but am worried about the cookie traffic, I could alleviate the problem by hosting my static content on a whole new domain such as static-example.com which would remain cookie free.

18

This is a minor consideration but one that is relevant for commercial sites. There is an expectation from non-technical users that a website starts with www so when they don't see that they might not think of a domain as a website.

Whilst it may seem silly to those of us that know how things work I have come across this attitude frequently with family, friends and non-technical colleagues and these people are likely to represent the vast majority of your customers.

Additionally, a lot of software such as email, world processors, social networking clients & co will automatically recognise a domain name starting with www as a hyperlink and make it active - with a naked, or non-www, domain you will need to add the http:// for the software to make it active. Being able to click a link instead of having to copy-paste into a browser could make the difference between a customer visiting your site or going to your competitor.

4
  • Actually I see a lot of advertising for domain names without the www. For example the BBC always quote their URL as bbc.co.uk/whatever when they always redirect to the www version. Commented Jul 12, 2010 at 21:07
  • +1 I totally agree on your minor consideration. It's true there is definitely "an expectation from non-technical users that a website starts with www" and it's also true: "so when they don't see that they might not think of a domain as a website". It sounds odd for tech users like us, but that's life. Commented Aug 27, 2010 at 13:43
  • Typically, if the URL doesn't start with www, I include http:// at the front. So if the URL is http://www.example.com, then I often just use www.example.com. If it was http://other.example.com, then I would use http://other.example.com. Otherwise, users don't realize it is a URL. Sounds crazy, but people mix up URLs and e-mail addresses all the time now. Sadly, we have dumbed-down things so much on the web, that our users don't know the basics any more.
    – Brad
    Commented Dec 2, 2010 at 14:50
  • Actually, what we did was expand the reach of the internet to people who never were educated in that regard. Ten years ago, you basically only got nerds on the internet. (Exaggeration.) Nowadays almost literally everyone uses facebook, google, "the internet". How many people are out there not knowing how a car works. Or a percolator. Or typesetting. (With varying degrees of relevancy.)
    – Cornelius
    Commented Apr 17, 2013 at 15:52
9

There doesn't seem to be any concrete reasons for using one over the other as far as search results or other desired outcomes. My personal preference is no-www, due to length.

The most important thing is to make sure you redirect to your preferred domain, and remember to set your preferred domain in Google Search Console (Google Webmaster Tools).

4

Without repeating the valid answers above regarding cookies, aesthetics, non-technical users expecting the www subdomain etc...

Another reason I tend to favour the www. subdomain approach for the main site is for local development. I use local. for my local test server. I always expect the site to be accessed via a subdomain and can easily distinguish between the test and live sites if required. Cookies can be kept separate from the local and live sites.

  • www.example.com Live site
  • local.example.com Local test server

Using a subdomain for the test server also allows easy testing from a mobile device, since the subdomain can be defined in the public DNS that points to a local test server (local IP). Only when the mobile device is on the local WiFi network will it be able to access the local test server. (Make sure that mobile browser optimisations are disabled when connecting locally, otherwise the remote optimisation server will also try to access your local server and fail.)

1

Yes, always use www instead of a naked domain. Although Heroku is somewhat specialized, the kind of routing fabric they've built is likely going to become more common as people deploy websites across clusters of machines. Naked domains are just much less flexible than www because they require an A instead of a CNAME record. See https://devcenter.heroku.com/articles/avoiding-naked-domains-dns-arecords.

Although you might not think so today, every site on the web should and hopefully soon will be using SSL all the time. That's because security is always better than no security, and the costs of SSL are already only ~1% additional CPU (see http://www.imperialviolet.org/2010/06/25/overclocking-ssl.html). You should get your SSL certificate for www as well.

0

My SEO people tell me Google doesn't like naked domains. A symptom of this is that if you try to redirect your myblog.blogspot.com blog to example.com/blog, you will get an error that says Blogs cannot be hosted at naked domains.

2
  • 2
    This is very dubious. Commented Feb 15, 2013 at 1:28
  • 1
    You can't do this because Blogger hosting on a custom domain is done using a CNAME to ghs.google.com, and the naked domain can't be a CNAME. Commented Apr 16, 2013 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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