我什么时候应该使用 rel=noreferrer?

When should I use rel=noreferrer?

我必须 link 其他一些外部站点。

我知道什么时候使用nofollow。但是我不清楚什么时候应该使用 rel=noreferrer.

简而言之,noreferrer link 类型会在单击 link 时隐藏引用信息 。带有 noreferrer link 类型的 link 看起来像这样:

<a href="http://www.example.com" rel="noreferrer">Click here for more info</a>

如果有人从使用此 link 类型的 link 到达您的网站,您的分析将不会显示谁引用了 link。相反,它会在您的获取渠道报告中错误地显示为直接流量。

如果您有一个外部 link 到您不信任的其他人的站点并且您想隐藏引荐来源信息,那么您可以将两者结合起来并使用

<a href="http://example.com/sample_page/" rel="noreferrer nofollow">Other Domain Link</a>

我建议您对以下内容使用nofollow links:

  • 评论或论坛中的链接 - 任何包含用户生成内容的内容都可能是垃圾邮件的来源。即使你小心谨慎,事情还是会漏掉。
  • 广告和赞助links - 任何link广告或赞助安排的一部分都必须禁止关注。
  • 付费 links - 如果您以任何方式对 link(目录提交、质量评估、评论等)收费,nofollow出站links

noreferrer 不仅会阻止 HTTP 引用 header,还会阻止 Javascript exploit involving window.opener

<a href="http://someurl.here" target="_blank">Link</a>
Looks innocuous enough, but there's a hole because, by default, the page that's being opened is allowing the opened page to call back into it via window.opener. There are some restrictions, being cross-domain, but there's still some mischief that can be done
window.opener.location = 'http://gotcha.badstuff';

使用 noreferrer 大多数浏览器将禁止 window.opener 利用

正如@unor 所说,它会在单击 link 时隐藏引荐来源信息。基本上,当您想向 linked 域的所有者隐藏用户来自您的网站时,这是一种隐私增强。

示例:

用户在您的网站上 www.mywebsite.com, there you have a <a href="https://newsite.com">Link</a>. When someone clicks the "Link" the owner of newsite.com knows it came from www.mywebsite.com。通过设置 rel=noreferrer,您可以防止泄露此信息。

它如何运作的一个很好的例子是从 21:28 of this conference talk. This is considered to be a good practice when working with server-side (e.g. Node.js). You can also read about this on the Helmet documentation.

开始

您只需要在私人页面或您不想做广告的页面上使用它。例如。网络邮件或私人错误跟踪器将被视为私人的,您不想 leak any information 到外部链接的网站。

敏感 public 页面,例如医疗信息或其他敏感主题,可能还需要屏蔽引荐来源网址 header。