WWW 与否,选择什么作为主站点名称?

从技术角度来看,唯一的问题是流量和传入链接(其中一个应该重定向到另一个)。

现在我需要选择哪一个应该是主要的。有些网站有 www (google,microsoft,ruby-lang) ,有些没有 www (stackoverflow,github)。在我看来,新的不使用 WWW。

选什么?

请解释一下。

更新: 这是编程相关的问题。实际上网站是为程序员准备的,所以我希望看看技术人员是怎么想的。

更新: 没有 WWW 的网站显然是赢家。谢谢大家!

24437 次浏览

It doesn't matter which you choose but you should pick one and be consistent. It is more a matter of style but it is important to note that search engines consider these two URLs to be different sites:

http://www.example.com
http://example.com

So whichever you choose for aesthetic reasons should be consistently used for SEO reasons.

Edit: My personal opinion is to forgo the www as it feels archaic to me. I also like shorter URLs. If it were up to me I would redirect all traffic from www.example.com to example.com.

I always make the non-www one redirect to www and refer to them as www.mysite; Think about various forums and instant messenging apps that correctly convert links only when they begin with www. .

Don't use WWW. It's an unnecessary tongue-twister, and a pain in the arse for graphic designers.

Configure both, obviously. I would make the www redirect to the normal URL, as it only exists to make the people who habitually type it at the beginning of every address happy anyway. Just don't, whatever you do, require the www to be typed manually. Ever.

I'd redirect to without www. In Apache 2.x:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule (.*) http://yourdomain.com/$1 [R=Permanent]

I think the www is meaningless; we all know we're on the world wide web. It would be much better to use subdomains for load balancing or for device specific sites (like m.google.com for mobiles, for example, even though there is a .mobi top level domain now).

It depends on your audience, I think. A non-technical audience will assume that the www is there, whereas a technical audience will not instinctively expect it, and will appreciate the shorter URLs.

(Edit: I recently set up a domain for my family to use, including webmail. My wife asked what the address of the webmail was. I said "mail.ourdomain.com". She typed "www.mail.ourdomain.com".)

Either way, make sure the one you don't use cleanly does a 301 Redirect to the one you do use - then neither users nor search engines will need to care.

You want your url to be memorable, and you want Google et al to register the same url for rankings and the like.

Best practice appears to be to handle the www, but always HTTP redirect it to a non-www variant. That way the search engines know to rank links to both variants as the same site.

Would you have other subdomains? If so, that may make using the www make more sense to my mind as some places may have various subdomains used for other purposes like a store or internationalization subdomains.

There are some issues you should consider. See for example Use Cookie-free Domains for Components for a cookie validity issue.

But regardless of how you decide: Use just one of that domains as your canonical domain name and use a 301 redirect to correct the invalid. For an Apache webserver, you can use mod_rewrite to do that.

I normally go with www.sitename.com because it is explicit that it is the main part of your site. Testing.sitename.com is testing. House.sitename.com is my home PC. I like be explicit however I do not mind when sites do not use www. I am not a purest. :)

One aspect of this question deals with CDNs and some web hosts (eg. Google Sites). Such hosts require that you add a CNAME record for your site name that points to the host servers. However, due to the way DNS is designed, CNAME records cannot coexist with other records for the same name, such as NS or SOA records. So, you cannot add a CNAME for your example.com name, and must instead add the CNAME for a subdomain. Of course people normally choose "www" for their subdomain.

Despite this technical limitation, I prefer to omit the www on my sites where possible.

www is used as a standard sub domain, subfolder for websites in the main domain.

http://no-www.org/ are trying to get it deprecated.

Although http://www.w3.org/ include www.

Worth checking both those sites.

It seems to be become a matter of taste and a religion issue at the moment rather than a standard. Whatever you choose, make sure you register or redirect from www as Control+enter etc. shortcuts copy in www.

Use without the www. The general rationale behind this is that since you are writing an address to a web browser, it's already implicit that you are accessing a web site (what else would you do with a browser?) - using the extra www is therefore useless.

To be specific, when receiving a http request, you know the user wants to access the website. The web browser adds the http://-header implicitly, so user only needs to worry about the address. Same goes to other services as well - if you host ftp, it should be enough to point the ftp client to the domain without the ftp. -prefix.

If I understand correctly, the reasons for using the different www., ftp., etc. subdomains are mostly historical, and are no longer relevant these days since traffic is simply directed to the correct server/service - the redundant prefixes have just stuck because of their popularity.

Whatever you use, stick to one or else you'll have to make 2 sets of cookies for each domain to make your sessions/cookies work properly.