什么时候应该使用“www”? 子域?

发布于 2024-07-13 14:11:49 字数 73 浏览 4 评论 0原文

过去几年浏览互联网时,我看到越来越多的页面摆脱了“www”子域。

使用或不使用“www”子域有什么充分的理由吗?

When browsing through the internet for the last few years, I'm seeing more and more pages getting rid of the 'www' subdomain.

Are there any good reasons to use or not to use the 'www' subdomain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

败给现实 2024-07-20 14:11:50

就在问这个问题之后,我来到了 no-www 页面,上面写着:

...简而言之,使用 www 子域
是多余且耗时的
交流。 互联网、媒体和
没有它,社会都会变得更好。

Just after asking this question I came over the no-www page which says:

...Succinctly, use of the www subdomain
is redundant and time consuming to
communicate. The internet, media, and
society are all better off without it.

就是爱搞怪 2024-07-20 14:11:50

从域名所有者处获取,同时使用 www.domainname.com 和普通的 domainname.com
否则,您只是将流量扔到浏览器搜索引擎(DNS 错误)

实际上,令人惊讶的是,有多少域名,尤其是前 100 个域名,正确解析为 www.domainname.com,但没有正确解析为 domainname.com

Take it from a domainer, Use both the www.domainname.com and the normal domainname.com
otherwise you are just throwing your traffic away to the browers search engine (DNS Error)

Actually it is amazing how many domains out there, especially amongst the top 100, correctly resolve for www.domainname.com but not domainname.com

大姐,你呐 2024-07-20 14:11:50

原因有很多,如下:

1) 人们故意想要这样

人们使用 DNS 做很多事情,而不仅仅是网络。 他们可能需要一些对他们来说更重要的其他服务的主 DNS 名称。

2) dns 服务器配置错误

如果有人在您的 dns 服务器上查找 www,您的 DNS 服务器将需要解析它。

3) Web 服务器配置错误

Web 服务器可以托管许多不同的网站。 它通过主机标头区分您想要的站点。 您需要指定您的网站要使用哪些主机名。

4) 网站优化

最好不要同时处理两者,而是使用已移动的永久 http 状态代码转发其中一个。 这样,这两个地址就不会竞争入站链接排名。

5) Cookie

避免浏览器不发回 Cookie 的问题。 这也可以通过永久移动http状态代码来解决。

6) 客户端浏览器缓存

如果您向 www 或其他网站发出请求,Web 浏览器可能不会缓存图像。 这也可以通过永久移动http状态代码来解决。

There are several reasons, here are some:

1) The person wanted it this way on purpose

People use DNS for many things, not only the web. They may need the main dns name for some other service that is more important to them.

2) Misconfigured dns servers

If someone does a lookup of www to your dns server, your DNS server would need to resolve it.

3) Misconfigured web servers

A web server can host many different web sites. It distinguishes which site you want via the Host header. You need to specify which host names you want to be used for your website.

4) Website optimization

It is better to not handle both, but to forward one with a moved permanently http status code. That way the 2 addresses won't compete for inbound link ranks.

5) Cookies

To avoid problems with cookies not being sent back by the browser. This can also be solved with the moved permanently http status code.

6) Client side browser caching

Web browsers may not cache an image if you make a request to www and another without. This can also be solved with the moved permanently http status code.

情感失落者 2024-07-20 14:11:50

使用 www 子域的原因有很多!

编写 URL 时,手写并输入“www.stackoverflow.com”比“http://stackoverflow.com”更容易。 大多数文本编辑器、电子邮件客户端、文字处理器和所见即所得控件将自动识别上述两者并创建超链接。 仅输入“stackoverflow.com”不会产生超链接,毕竟它只是一个域名。谁说那里有 Web 服务? 谁说对该域的引用就是对其 Web 服务的引用?

您更愿意写/输入/说什么..“www”。 (4 个字符)或“http://”(7 个字符)?

“万维网。” 是一种既定的速记方式,用于明确传达以下事实:主题是网址,而不是其他网络服务的 URL。

当口头交流网址时,从上下文中应该可以清楚地看出这是一个网址,因此说“www”是多余的。 服务器应配置为返回 HTTP 301(永久移动)响应,将对 @.stackoverflow.com(域的根)的所有请求转发到 www 子域。

根据我的经验,认为应该省略 WWW 的人往往是不理解 web 和 internet 之间的区别并且可以互换使用这些术语的人,就像它们是同义词一样。 网络只是众多网络服务之一。

如果你想摆脱 www,为什么不更改你的 HTTP 服务器以使用不同的端口呢,TCP 端口 80 昨天已经太厉害了.. 让我们将其更改为端口 1234,是的,现在人们必须说并输入“http://stackoverflow.com:1234"(八个三通三通小便冒号斜杠斜杠堆栈溢出点com冒号一二三四)但至少我们不必说“www”吧?

There are MANY reasons to use the www sub-domain!

When writing a URL, it's easier to handwrite and type "www.stackoverflow.com", rather than "http://stackoverflow.com". Most text editors, email clients, word processors and WYSIWYG controls will automatically recognise both of the above and create hyperlinks. Typing just "stackoverflow.com" will not result in a hyperlink, after all it's just a domain name.. Who says there's a web service there? Who says the reference to that domain is a reference to its web service?

What would you rather write/type/say.. "www." (4 chars) or "http://" (7 chars) ??

"www." is an established shorthand way of unambiguously communicating the fact that the subject is a web address, not a URL for another network service.

When verbally communicating a web address, it should be clear from the context that it's a web address so saying "www" is redundant. Servers should be configured to return HTTP 301 (Moved Permanently) responses forwarding all requests for @.stackoverflow.com (the root of the domain) to the www subdomain.

In my experience, people who think WWW should be omitted tend to be people who don't understand the difference between the web and the internet and use the terms interchangeably, like they're synonymous. The web is just one of many network services.

If you want to get rid of www, why not change the your HTTP server to use a different port as well, TCP port 80 is sooo yesterday.. Let's change that to port 1234, YAY now people have to say and type "http://stackoverflow.com:1234" (eightch tee tee pee colon slash slash stack overflow dot com colon one two three four) but at least we don't have to say "www" eh?

不即不离 2024-07-20 14:11:50

包含或不包含它并没有太大的优势,也没有一种客观上最好的策略。 “no-www.org”是一堆愚蠢的旧教条,试图将自己呈现为明确的事实。

如果“拥有许多不同服务并且不想将裸域名专用于 Web 服务器的大型组织”场景不适合您(实际上很少如此),那么您选择的地址是很大程度上是一个文化问题。 如果人们习惯于在广告材料上看到裸露的“example.org”域名,他们会立即将其识别为没有额外“www”或“http://”的网址吗? 例如,在日本,如果您选择非 www 版本,您会得到有趣的表情。

但无论你选择哪一个,都要保持一致。 让 www 和非 www 版本都可访问,但其中一个是明确的,始终链接到该版本,并使另一个重定向到该版本(永久,状态代码 301)。 让两个主机名直接响应对 SEO 不利,并且提供解析到您的服务器的任何旧主机名会让您容易受到 DNS 重新绑定攻击。

There is no huge advantage to including-it or not-including-it and no one objectively-best strategy. “no-www.org” is a silly load of old dogma trying to present itself as definitive fact.

If the “big organisation that has many different services and doesn't want to have to dedicate the bare domain name to being a web server” scenario doesn't apply to you (and in reality it rarely does), which address you choose is a largely cultural matter. Are people where you are used to seeing a bare “example.org” domain written on advertising materials, would they immediately recognise it as a web address without the extra ‘www’ or ‘http://’? In Japan, for example, you would get funny looks for choosing the non-www version.

Whichever you choose, though, be consistent. Make both www and non-www versions accessible, but make one of them definitive, always link to that version, and make the other redirect to it (permanently, status code 301). Having both hostnames respond directly is bad for SEO, and serving any old hostname that resolves to your server leaves you open to DNS rebinding attacks.

未蓝澄海的烟 2024-07-20 14:11:50

除了有关 cookie 的负载优化之外,使用 www 子域还有一个与 DNS 相关的原因。 您不能对裸域使用 CNAME。 在 yes-www.org (已保存)它说:

当使用 HerokuAkamai 等提供商来托管您的网站时,提供商希望能够更新 DNS 记录,以防需要重定向流量故障服务器到健康服务器。 这是使用 DNS CNAME 记录设置的,裸域不能有 CNAME 记录。
只有当您的网站变得足够大,需要使用此类服务​​进行高度冗余托管时,这才是一个问题。

Apart from the load optimization regarding cookies, there is also a DNS related reason for using the www subdomain. You can't use CNAME to the naked domain. On yes-www.org (saved) it says:

When using a provider such as Heroku or Akamai to host your web site, the provider wants to be able to update DNS records in case it needs to redirect traffic from a failing server to a healthy server. This is set up using DNS CNAME records, and the naked domain cannot have a CNAME record.
This is only an issue if your site gets large enough to require highly redundant hosting with such a service.

不必在意 2024-07-20 14:11:50

正如 jdangel 指出的那样,在某些 cookie 情况下 www 是一种很好的做法,但我相信使用 www 还有另一个原因。

关心和保护我们的用户难道不是我们的责任吗? 正如大多数人所期望的那样,如果不针对 www 进行编程,您会给他们带来不完美的体验。

对我来说,仅仅因为理论上不需要就不设置 DNS 条目似乎有点傲慢。 携带 DNS 条目没有任何开销,并且通过重定向等,它们可以重定向到非 www dns 地址。

说真的,不要因为给潜在访问者留下不必要的“网站未找到”错误而失去宝贵的流量。

另外,在仅限 Windows 的网络中,您也许可以设置 Windows DNS 服务器来避免以下问题,但我认为您不能在 Mac 和 Windows 的混合环境中这样做。 如果 Mac 对 Windows DNS 进行 DNS 查询,mydomain.com 将返回所有可用的名称服务器,而不是 Web 服务器。 因此,如果在浏览器中输入 mydomain.com ,您的浏览器将查询名称服务器而不是网络服务器,在这种情况下,您需要一个子域(例如 www.mydomain.com )来指向特定的网络服务器。

As jdangel points out the www is good practice in some cookie situations but I believe there is another reason to use www.

Isn't it our responsibility to care for and protect our users. As most people expect www, you will give them a less than perfect experience by not programming for it.

To me it seems a little arrogant, to not set up a DNS entry just because in theory it's not required. There is no overhead in carrying the DNS entry and through redirects etc they can be redirected to a non www dns address.

Seriously don't loose valuable traffic by leaving your potential visitor with an unnecessary "site not found" error.

Additionally in a windows only network you might be able to set up a windows DNS server to avoid the following problem, but I don't think you can in a mixed environment of mac and windows. If a mac does a DNS query against a windows DNS mydomain.com will return all the available name servers not the webserver. So if in your browser you type mydomain.com you will have your browser query a name server not a webserver, in this case you need a subdomain (eg www.mydomain.com ) to point to the specific webserver.

纵情客 2024-07-20 14:11:50

某些站点需要它,因为该服务在特定设置上配置为仅通过 www 子域传递 Web 内容。

这是正确的,因为 www 是“万维网”流量的传统子域。
正如端口 80 是标准端口一样。 显然还有其他标准服务和端口(端口 80 上的 http tcp/ip 没什么特别的!)

想象一下 mycompany...

mx1.mycompany.com 25 smtp 等

ftp.mycompany.com 21 ftp

www.mycompany.com 80 http

不需要它的站点基本上都有 dns 转发或某种重定向。

例如

*.mycompany.com 80 http

据我所知,这样做的唯一原因是您是否喜欢它并且想要这样做。

Some sites require it because the service is configured on that particular set up to deliver web content via the www sub-domain only.

This is correct as www is the conventional sub-domain for "World Wide Web" traffic.
Just as port 80 is the standard port. Obviously there are other standard services and ports as well (http tcp/ip on port 80 is nothing special!)

Imagine mycompany...

mx1.mycompany.com 25 smtp, etc

ftp.mycompany.com 21 ftp

www.mycompany.com 80 http

Sites that don't require it basically have forwarding in dns or redirection of some-kind.

e.g.

*.mycompany.com 80 http

The onlty reason to do it as far as I can see is if you prefer it and you want to.

手心的海 2024-07-20 14:11:50

我说总是使用 www,因为它可以让您在需要时更轻松地升级,因为您可以使用 ww2 或我最喜欢的备份子域,wwv,因为它看起来几乎像 www,所以大多数用户不会看它。 使用更多服务器进行升级的能力非常有用。 我可以有 4 个备份服务器,其子域为 wwv wwu wwww wwwv

I say ALWAYS use www because it allows you to easier upscale when needed because you can use ww2 or my favorite backup subdomain, wwv because it looks almost like www so most users will just not look at it. the ability to upscale with more servers is very useful. I can have 4 backup servers with the subdomains wwv wwu wwww wwwv

辞别 2024-07-20 14:11:49

包含它有很多充分的理由,其中最好的理由如下:
Yahoo 性能最佳实践

由于 cookie 的点规则,如果您不这样做有“www”。 那么你就不能像*.example.com那样设置两点cookie或跨子域cookie。 有两个相关的影响。

首先,这意味着您向其提供 cookie 的任何用户都会将这些 cookie 与与域匹配的请求一起发回。 因此,即使您有一个子域 images.example.com,example.com cookie 也将始终随请求一起发送到该域。 这会产生一些开销,如果您将 www.example.com 设为权威名称,则不会存在这种开销。 当然,您可以使用 CDN,但这取决于您的资源。

此外,您也无法设置跨子域 cookie。 这似乎是显而易见的,但这意味着允许经过身份验证的用户在子域之间移动更多的是一个技术挑战。

所以问自己一些问题。 我要设置cookie吗? 我是否关心潜在不必要的带宽支出? 经过身份验证的用户会跨子域吗? 如果您确实担心给用户带来不便,您可以随时将服务器配置为自动处理 www/no www 问题。

请参阅 dropwwwyes-www已保存< /a>)。

There are a ton of good reasons to include it, the best of which is here:
Yahoo Performance Best Practices

Due to the dot rule with cookies, if you don't have the 'www.' then you can't set two-dot cookies or cross-subdomain cookies a la *.example.com. There are two pertinent impacts.

First it means that any user you're giving cookies to will send those cookies back with requests that match the domain. So even if you have a subdomain, images.example.com, the example.com cookie will always be sent with requests to that domain. This creates overhead that wouldn't exist if you had made www.example.com the authoritative name. Of course you can use a CDN, but that depends on your resources.

Also, you then don't have the ability to set a cross-subdomain cookie. This seems evident, but this means allowing authenticated users to move between your subdomains is more of a technical challenge.

So ask yourself some questions. Do I set cookies? Do I care about potentially needless bandwidth expenditure? Will authenticated users be crossing subdomains? If you're really concerned with inconveniencing the user, you can always configure your server to take care of the www/no www thing automatically.

See dropwww and yes-www (saved).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文