0

很多人谈论 301 将传入请求重定向到一个规范 url 以用于 SEO 或其他目的。

这可能很有用。假设例如,如果搜索引擎对 url 进行了排名,并且不幸地处理了带有 www 的 url。并没有不同。例如,对于 Facebook,有http://facebook.comhttp://www.facebook.com(甚至更多,如 https://)。

我想我的问题是,如果有区别,总体上重定向到带有 www 的 url 会更好吗?子域,或没有?推理将不胜感激。谢谢你。

4

1 回答 1

1

Often, shorter is better (e.g. use domain.com instead of www.domain.com), since your URLs will be shorter and thus your HTTP requests and responses will also be smaller.

However, one thing to keep in mind is that if your site uses cookies, and you set a cookie on domain.com, that will get sent to all subdomains. If you want to keep a "cookieless" subdomain for performance reasons (e.g. requests for images at images.domain.com don't carry the cookies) then you should consider using the "www." prefix in the canonical URLs if you need cookies to be sent in the requests for pages but not for sub-resources.

You'll also want to use the "www." form if your domain is of a funky (ccTLD) format like XX.YY, because cookies work properly on www.XX.YY but you'll have problems with older browsers if you try to set cookies on XX.YY.

于 2013-08-15T05:33:49.733 回答