301 Redirect vs. Rel =规范 [英] 301 Redirect vs. Rel=Canonical

查看:211
本文介绍了301 Redirect vs. Rel =规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的网站上,可以跨域访问特定于区域设置的URL.

假设我们有两个URL:dog.aspx(英语)和hund.aspx(德语).

以下网址有效:

  • www.example.com/hund.aspx(显示英语内容,而不是德语,但URL是德语)
  • www.example.de/hund.aspx(正确的网址)

要解决此问题,我们有两个选择:

  • www.example.com/hund.aspx重定向到www.example.com/dog.aspx

  • www.example.com/hund.aspx中具有canonical URL到www.example.com/dog.aspx

更可取的是什么? 301重定向还是canonical URL?

解决方案

301重定向优于canonical声明.

用户代理不能绕过重定向,而canonical只是以下建议:a)并非所有用户代理都支持,并且b)甚至支持它的用户代理也没有必须遵循它.

RFC 6596 也建议:

在添加规范链接关系之前,建议对以下内容进行验证:

  1. […]

  2. 对于HTTP,永久性HTTP重定向([RFC2616]的10.3.2节)是IRI内容已被永久移动的传统强项,无法代替规范的链接关系来实现.

  3. p>
  4. […]

On our site, locale specific URLs are accessible across domains.

Say we have two URLs: dog.aspx (English) and hund.aspx (German).

The following URLs work:

  • www.example.com/hund.aspx (displays English content, not German,but URL is German)
  • www.example.de/hund.aspx (correct URL)

To solve this, we have two options:

  • www.example.com/hund.aspx redirect to www.example.com/dog.aspx

  • Have canonical URL in www.example.com/hund.aspx to www.example.com/dog.aspx

What is more preferable? 301 redirect or canonical URL?

解决方案

A 301 redirect is preferable to a canonical declaration.

User agents can’t bypass redirects, while canonical is only an advice which a) not all user agents support, and b) even user agents that support it don’t have to follow it.

RFC 6596 recommends this, too:

Before adding the canonical link relation, verification of the following is RECOMMENDED:

  1. […]

  2. For HTTP, permanent HTTP redirects (Section 10.3.2 of [RFC2616]), the traditional strong indicator that a IRI's content has been permanently moved, could not be implemented in place of the canonical link relation.

  3. […]

这篇关于301 Redirect vs. Rel =规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆