6

我知道将您的网站完全保留为“http://www”或 http:// 是一种很好的做法,而且我也知道 www 只是一个子域。

我的主要问题是其中哪一个是最佳选择?我现在正在为我的一台服务器配置 htaccess,并且无法决定将所有流量重定向到 www 子域。(顺便说一句,我知道该怎么做。)

这只是一个最佳实践问题。我看到像谷歌和亚马逊这样的大公司都转发到 www 子域,但对我来说这听起来没有必要——我不想错过任何东西。

谢谢!

4

4 回答 4

7

有趣的是,我去年花了太多时间为我的一个公司网站研究这个。我得出的结论是,只要您将一个重定向到另一个(用户可以在任一版本中找到您)都没有关系。在过去的 10 年里,我一直使用 www 子域。从去年开始,我所有的新项目都没有它,因为它是不必要的——也可以保存 4 个字符。

于 2012-06-28T14:35:18.617 回答
2

My vote clearly goes for No WWW. Besides the fact that those four bytes (www.) are passed back and forth with each request/answer (every byte counts, right?). My clients are happy with this!

When one asks about printing on their business card or letterhead: "Will people know it is an Internet address, if it does not start with www?" I tell them to go ahead and print the www, just leave off the first dot!

On Printed Paper, I have seen my clients write all of these. However, most clients now prefer the first format to imitate CNN.COM:

  1. www example.com
  2. www: example.com
  3. web: example.com
  4. Internet: example.com

Then if people use the dot, or not, it ends up at the right address (without all those extra bytes!)

Clearly, more people are following CNN.COM and moving away from www for most sites.

The easy solution I use from No WWW, Better SEO is to start each .htaccess with the following:

RewriteEngine On
RewriteBase /

# FROM www. --TO-- NO www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

This is just a cut and paste no-brainer. It is the first thing on each .htaccess I have on hundreds of sites and domains.

EDIT 2014/04/22

Reason to use a Subdomain: Cookies

There is one consideration for using a subdomain (like www, but not always www) and that is cookies.

If you assign a cookie for a domain it may be available to all subdomains (at least if not done very carefully!).

For example:

  • example.com cookies would be available for
  • philippines.example.com

Whereas:

  • www.example.com cookies or
  • earth.example.com would not be available for
  • philippines.example.com

A better plan would be to have everything on a logical subdomain and direct the bare domain to one of them...

For example:

  • earth.example.com
  • canada.example.com
  • philippines.example.com
  • usa.example.com

You would remove all www. from domains like www.usa.example.com and redirect example.com to earth.example.com (or web.example.com, or main.example.com or w.example.com!).

This way each subdomain could share the cookies of example.com and could have there own cookies too!

Of course, most websites do not use multiple subdomains, and therefore have no conflicts with cookies, and no reason at all to use the www.

EDIT 2017/12/12 - Static Content

Reason to NOT use a Subdomain: Static Content

One thing I didn't mention was Cookieless Static Content. Like many big sites, I use a separate domain for this.

Cookied Website Domain

  • example-1.com

Cookieless Static Content.

  • static-example.com -

If you have many sites, you can set up one for Static Content.

Cookied Sites:

  1. plant-only.org
  2. vekind.org
  3. fyuel.org
  4. tait.asia

Domain for Cookieless Static Content.

  • my-static-content.info
    1. plant-only.my-static-content.info - for plant-only.org
    2. vekind.my-static-content.info - for vekind.org
    3. fyuel.my-static-content.info - for fyuel.org
    4. tait.my-static-content.info - for tait.asia

Reason to NOT use a Subdomain: Green Website

Another reason to NOT use the www. is the "green" reason or the carbon footprint. With all things being equal... - www.example.com has a bigger carbon footprint than - w.example.com which is still bigger than - example.com

If one cares about their carbon footprint, or if a website claims to be "green", then they should not employ the "www." in their website address as these four characters would add to their carbon footprint in transmitting their domain name (howbeit a very small amount!).

Let a website prove they are really green by getting rid of the "www." in their domain!

Reason to NOT use a Subdomain: Psychological

Another reason to NOT use the "www." is the "psychological" aspects of writing code. Most programmers think in terms of the bare website. For example, I am working on SEO for a website called AngBarato.Com (it means "the cheap dot com" in Filipino. and is a buy and sell site). About half the links are to www.angbarato.com pages, and a half to angbarato.com pages. It was the coder's intention to use "www.", yet half the time he wrote the domain without the "www."

I convinced him these errors were very hard to find and deal with. For example, using the text editor Geany, we did a search for angbarato.com. Of course, all links appeared (some with and some without the "www."). On the other hand, doing a replace "www." for "" fixed all the links (and SEO) immediately!

Looking for "www.", and removing it, is a lot easier to debug than to look for where "www." does not exist, and quickly adding "www." to each missing link! Even worse if there are subdomains like www.usa.angbarato.com.

于 2012-10-16T05:26:31.790 回答
1

除非您打算将您的网站放在证书后面,否则我建议您让两个主机都可以访问。

于 2012-06-28T14:36:33.207 回答
0

底线;这并不重要,只要两者仍然可以访问。

我倾向于删除www。大多数时候,因为从技术上讲它不再需要。

但是,对于较短的域名,请添加 www。有时使它在视觉上看起来更好。有点像室内设计,你需要有奇数个项目。egwww.xyzjk.com看起来很对称,有3对字符(奇数)。我想这就是谷歌使用www.google.com而不是google.com.

另一件事是,在某些 CMS 或论坛中,url 必须以其中之一开头http://www.转换为可点击的超链接。因此,为了可能获得一些额外的传入链接,您可能更喜欢 www。

于 2012-06-28T16:07:49.997 回答