从您的网站中删除 WWW 前缀 [英] Remove WWW prefix from your website
问题描述
当作为 URL 的一部分输入时,Stack Overflow(和其他网站)如何删除www"前缀?
How does Stack Overflow (and other web sites) remove the 'www' prefix when it's entered as part of a URL?
它是重定向、重写还是其他完全不同的东西?
Is it a redirect, a rewrite or something else entirely?
更新:我特别想在 IIS 6 的上下文中了解
Update: I'd specifically like to know in the context of IIS 6
推荐答案
启动 Fiddler,我们可以看到 服务器 以301 永久移动"状态响应并将其引用到 http://stackoverflow.com .由于 StackOverflow 托管在 Windows 2k8 IIS7 上,他们直接在 IIS7 中设置了此重定向.
Firing up Fiddler, we can see that the server responses with a "301 Moved Permanently" status and refers it to http://stackoverflow.com . Since StackOverflow is hosted on Windows 2k8 IIS7 they set up this redirect straight away in IIS7.
仅供参考:
如果您是 .NET 开发人员,您可能知道 "Respose.Redirect" ,这会创建 302 Object Moved 状态.在这种情况下,搜索引擎更喜欢 301 状态代码,因为他们知道他们将来不应该回到 www.stackoverflow.com.
If you are a .NET developer you might know "Respose.Redirect" , this creates a 302 Object Moved status. Search engines like 301 status codes in this case better, because they know they should not come back to www.stackoverflow.com in the future.
这篇关于从您的网站中删除 WWW 前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!