Should I default my website to www.foo or not?

2019-01-21 23:11发布

Notice how the default domain for stackoverflow is http://stackoverflow.com and if you try to goto http://www.stackoverflow.com it bounces you to http://stackoverflow.com ?

What is the reason for this? Not the tech reason (as in the http code, etc) but why would the site owners want to do this?

I know it's purely aesthetic and I always have host-headers for both www and not, but is there a reason to bounce a user to a single domain, subheaded or not?

Update 1

Not having a subdomain is called a bare domain. Thanks peeps! never knew it had a term :)

Update 2

Thanks for the answers so far - please note I understand that www.domain.com can point to domain.com. This is not a question about if i should offer both or either/or, it's asking why some sites default to a baredomain instead of www subdomains, or vice-versa. Cheers.

Jeff Atwood actually HAS explained why he's gone for bare domains here and here. (Nod to Jonas Pegerfalk for the post :) )

Jeff's post (and others in this thread) also talk about the problems of a bare domain with cookies and static images. Basically, if you have cookies on in a bare domain, then all subdomains are forced also. The solution is to purchase another domain, as posted by the Yahoo Perf Team here.

8条回答
戒情不戒烟
2楼-- · 2019-01-21 23:25

actually you can use both of them. So it's better to find user your address or some. I mean actually it doesn't really matter tho :)

But putting www as a prefix is more common in public so I guess I'd prefer to use www behind it.

查看更多
干净又极端
3楼-- · 2019-01-21 23:30

Jeff Atwood has written a great article about the The Great Dub-Dub-Dub Debate. There is also a blog entry in the Stackoverflow blog on why and how Stackoverflow has dropped the www prefix.

查看更多
beautiful°
4楼-- · 2019-01-21 23:33

In some cases, www might indeed point to a completely separate subdomain in a large corporate environment. Especially on an internal network, having the explicit www can make split DNS easier if the Web site is hosted externally (say, at Rackspace in Texas, but everything else is in your office in Virginia.) In most cases, it doesn't matter.

The important thing is to pick one and add an IHttpModule, rewrite rule, or equivalent for your platform to permanently redirect requests from one to the other.

Having both can lead to scary certificate warrnings when switching from http to https if you don't have a wildcard certificate and forget to explicitly redirect based on your site's name (which you probably don't because you want your code to work in both dev and production, so you're using some variable populated by the server).

Much more importantly, having both accepted results in search engines seeing duplicated content--you get dinged for having duplicated content, and you get dinged because your hits are getting split across two different URIs, hurting your rankings.

查看更多
Animai°情兽
5楼-- · 2019-01-21 23:33

I'm not sure why the StackOVerflow team decided to use only one, but if it were me, I'd do it for simplicity. You'd have to allow for both since a lot of people type www by default or out of habit (I'm sure less "techy" people have no idea that there's a difference).

Aside from that, there used to be a difference as far as search engines were concerned and so there was concern about having either a duplicate content penalty or having link reputation split. But this has long since been handled and so isn't much of a consideration at this point.

So I'd say it's pretty much personal preference to keep things simple.

查看更多
冷血范
6楼-- · 2019-01-21 23:34

as far as I can tell, it doesn't really matter, but you should pick one or the other as the default, and forward to that.

the reason is that, depending on the browser implementation, www.example.com cookies are not always accessible to example.com (or is it the other way around?)

for more discussion on this, see:

in favor of www

  • http://faq.nearlyfreespeech.net/section/domainnameservice/baredomain#baredomain - This webhost lists several good reasons for anyone considering doing more than simple webhosting to consider (such as load balancing, subdomains with different content, etc.)

  • http://yes-www.org - This blog post from 2005 mainly proposed that most internet users needed the www prefix in order to recognize a URL. This is less important now that browsers have built-in searching. Most computer illiterates I know bypass the URL bar entirely.

in opposition to www

and a miscellaneous related rant about why www should not be used as a CNAME, but only as an A RECORD.

查看更多
叛逆
7楼-- · 2019-01-21 23:40

It's easier to type google.com than www.google.com, so give the option of both. remember, the www is just a subdomain.

Also no www is a commonplace these days, so maybe make the www.foo.com redirect to foo.com.

查看更多
登录 后发表回答