请注意 stackoverflow 的默认域是 http://stackoverflow.com,并且如果您尝试转到 http://www.stackoverflow.com 它会将您跳转到 http://stackoverflow.com 吗?
这是什么原因呢? 不是技术原因(如 http 代码等),而是网站所有者为什么要这样做?
我知道这纯粹是为了美观,而且我总是有 www 和非 www 的主机标头,但是是否有理由将用户弹回单个域,无论是否有副标题?
更新 1
没有子域称为裸域。 谢谢偷看! 从来不知道它有一个术语:)
更新 2
感谢您迄今为止的回答 - 请注意,我了解 www.domain.com 可以指向域。 com. 这不是一个关于我是否应该提供两者或其中之一/或的问题,而是问为什么有些网站默认使用裸域而不是 www 子域,反之亦然。 干杯。
Jeff Atwood 实际上已经解释了为什么他选择裸域这里和此处。 (向 Jonas Pegerfalk 致敬这篇文章:))
Jeff 的帖子(以及本线程中的其他帖子)也讨论了带有 cookie 和静态图像的裸域的问题。 基本上,如果您在裸域中启用了 cookie,那么所有子域也会被强制。 解决方案是购买另一个域名,正如 Yahoo Perf 团队在此处发布的 。
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)
杰夫·阿特伍德 (Jeff Atwood) 写了一篇关于 The Great Dub-Dub- 的精彩文章配音辩论。 Stackoverflow 博客中还有一个博客条目,介绍 Stackoverflow 为何以及如何删除 www 前缀< /a>.
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.
据我所知,这并不重要,但您应该选择其中之一作为默认值,然后转发到该选项。
不同,
www.example.com
cookie 并不总是可以被example.com
访问(或者是相反?)原因是,根据浏览器实现的 有关于此的更多讨论,请参阅:
支持 www
http://faq.nearlyfreespeech.net/section/domainnameservice/baredomain#baredomain - 此虚拟主机列出了任何考虑做简单虚拟主机以外的人的几个充分理由(例如负载平衡、具有不同内容的子域、等)
http://yes-www.org - 这2005 年的博客文章主要提出大多数互联网用户需要
www
前缀才能识别 URL。 由于浏览器具有内置搜索功能,这一点已不再那么重要。 据我所知,大多数电脑文盲完全绕过了 URL 栏。反对 www
以及关于为什么 www 不应该用作
CNAME
而只能用作A RECORD
的各种相关咆哮。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 toexample.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 anA RECORD
.值得注意的是,您不能在 DNS 中的同一(裸域名)名称上拥有 CNAME 和 NS 记录。 因此,如果您使用 CDN 并需要为您的 Web 服务器设置 CNAME 记录,那么如果您使用的是裸域,则无法执行此操作。 您必须使用“
www
”或其他一些前缀。话虽如此,我更喜欢不带“
www.
”前缀的 URL 外观,因此我对所有网站都使用裸域。 (我不需要 CDN。)当我提到面向公众的 URL(例如名片上)时,我觉得必须使用 www.< /code> 前缀或
http://
前缀。 否则,仅仅一个裸域名并不能告诉人们他们一定可以将其输入到浏览器中。 因此,由于我认为http://
是名片上丑陋的疣,所以我确实在那里使用了www.
前缀。真是一团糟。
It is worth noting that you can't have CNAME and an NS record on the same (bare domain) name in DNS. So, if you use a CDN and need to set up a CNAME record for your web server, you can't do it if you are using a bare domain. You must use "
www
" or some other prefix.Having said that, I prefer the look of URLs without the "
www.
" prefix so I use a bare domain for all my sites. (I don't need a CDN.)When I am mentioning URLs for the general public (eg. on a business card), I feel that one has to use either the
www.
prefix or thehttp://
prefix. Otherwise, just a bare domain name doesn't tell people they can necessarily type it into their browser. So, since I considerhttp://
an ugly wart on a business card, I do use thewww.
prefix there.What a mess.
在某些情况下,www 可能确实指向大型企业环境中完全独立的子域。 特别是在内部网络上,如果网站托管在外部(例如,在德克萨斯州的 Rackspace,但其他一切都在弗吉尼亚州的办公室中),则拥有显式 www 可以使拆分 DNS 变得更容易。在大多数情况下,这并不重要。
重要的是选择一个并为您的平台添加 IHttpModule、重写规则或等效项,以将请求从一个永久重定向到另一个。
如果您没有通配符证书并且忘记根据站点名称显式重定向(您可能不这样做,因为您希望代码在两个开发环境中工作),那么从 http 切换到 https 时,同时拥有这两种证书可能会导致可怕的证书警告和生产,因此您正在使用服务器填充的一些变量)。
更重要的是,在搜索引擎中看到重复的内容时,这两个结果都会被接受——你会因为重复的内容而受到指责,并且因为你的点击被分散在两个不同的 URI 上,从而损害了你的排名。
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.
实际上你可以同时使用它们。 所以最好找到用户您的地址或其他地址。 我的意思是实际上这并不重要:)
但是将 www 作为前缀在公共场合更常见,所以我想我更喜欢在其后面使用 www 。
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.
输入 google.com 比输入 www.google.com 更容易,因此请同时选择这两个选项。 请记住,www 只是一个子域。
而且现在没有 www 已经很常见了,所以也许可以将 www.foo.com 重定向到 foo.com。
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.
我认为原因之一是帮助搜索排名,以便每个页面只有一个页面获得排名,而不是分成两个域。
I think one reason is to help with search rankings so that for each page only one page is getting rankings instead of being split between two domains.
我不确定为什么 StackOVerflow 团队决定只使用一个,但如果是我,我会为了简单起见而这样做。 你必须考虑到两者,因为很多人默认或出于习惯输入 www (我确信不太“技术”的人不知道有什么区别)。
除此之外,就搜索引擎而言,过去存在差异,因此人们担心重复内容处罚或链接信誉分裂。 但这早已得到处理,因此目前无需考虑太多。
所以我想说,让事情变得简单几乎是个人喜好。
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.