Referrer-Policy

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.

* Some parts of this feature may have varying levels of support.

Referrer-PolicyHTTP ヘッダーで、 (Referer ヘッダーで送られる) リファラー情報をリクエストにどれだけ含めるかを制御します。 HTTP ヘッダーのほかに、 HTML でこのポリシーを設定することもできます。

ヘッダー種別 レスポンスヘッダー
禁止ヘッダー名 いいえ

構文

Referrer-Policy: no-referrer
Referrer-Policy: no-referrer-when-downgrade
Referrer-Policy: origin
Referrer-Policy: origin-when-cross-origin
Referrer-Policy: same-origin
Referrer-Policy: strict-origin
Referrer-Policy: strict-origin-when-cross-origin
Referrer-Policy: unsafe-url

メモ: 元のヘッダー名である Referer は "referrer" という語のスペルミスです。 Referrer-Policy ヘッダーはこのスペルミスをしていません。

ディレクティブ

no-referrer

Referer ヘッダーが省略されます。送信されるリクエストにはリファラー情報が含まれません。

no-referrer-when-downgrade

プロトコルのセキュリティ水準が同一である、または向上する場合 (HTTP→HTTP, HTTP→HTTPS, HTTPS→HTTPS) は、オリジン、パス、クエリー文字列が Referer ヘッダーで送信されます。セキュリティ水準が低下するリクエスト (HTTPS→HTTP, HTTPS→file) では Referer ヘッダーが送信されません。

origin

オリジンのみが Referer ヘッダーで送信されます。 たとえば、 https://example.com/page.html にある文書からは、 https://example.com/ というリファラーが送信されます。

origin-when-cross-origin

同一のプロトコル水準 (HTTP→HTTP, HTTPS→HTTPS) で同一オリジンのリクエストを行う場合はオリジン、パス、クエリー文字列を送信します。オリジン間リクエストや安全性の低下する移動先 (HTTPS→HTTP) ではオリジンのみを送信します。

same-origin

同一オリジンのリクエストではオリジン、パス、クエリー文字列を送信します。オリジン間リクエストでは Referer ヘッダーを送信しません。

strict-origin

プロトコルのセキュリティ水準が同じである場合 (HTTPS→HTTPS) にのみオリジンを送信します。安全性の低下する移動先 (HTTPS→HTTP) には Referer ヘッダーを送信しません。

strict-origin-when-cross-origin (既定値)

同一オリジンのリクエストを行う際はオリジン、パス、クエリー文字列を送信します。オリジン間リクエストでは、プロトコルのセキュリティ水準が同じである場合 (HTTPS→HTTPS) にのみオリジンを送信します。安全性の低下する移動先 (HTTPS→HTTP) には Referer ヘッダーを送信しません。

メモ: これはポリシーが指定されていない場合や、与えられた値が無効であった場合の既定のポリシーです (仕様書改訂 November 2020 を参照) 。以前の既定値は no-referrer-when-downgrade でした。

unsafe-url

セキュリティに関係なく、どのリクエストを行った場合でも、オリジン、パス、クエリー文字列を送信します。

警告: このポリシーは、 HTTPS リソースの URL から安全ではないオリジンへプライベートである可能性がある情報を漏洩します。設定する場合は影響をよく検討してください。

HTML との統合

HTML 内でリファラーポリシーを設定することもできます。例えば、 <meta> 要素で namereferrer を設定することで、文書全体のリファラーポリシーを設定することができます。

html
<meta name="referrer" content="origin" />

<a>, <area>, <img>, <iframe>, <script>, <link> の各要素に referrerpolicy 属性を指定し、個別のリクエストにリファラーポリシーを設定することもできます。

html
<a href="http://example.com" referrerpolicy="origin"></a>

他に、 noreferrer link 関係a, area, link の各要素に設定することもできます。

html
<a href="http://example.com" rel="noreferrer"></a>

警告: 上記のように、 noreferrer link 関係はダッシュ記号を用いずに記述されます。 <meta> 要素で文書全体のリファラーポリシーを指定するときはダッシュをつけて <meta name="referrer" content="no-referrer"> のように記述します。

CSS との統合

CSS はスタイルシートから参照されるリソースにアクセスすることがあります。これらのリソースは同様にリファラーポリシーに従います。

  • 外部の CSS スタイルシートでは、そのレスポンスの Referrer-Policy ヘッダーにより上書きされない限り、既定のポリシー (strict-origin-when-cross-origin) が使用されます。
  • <style> 要素または style 属性については、所有者の文書のリファラーポリシーが使用されます。

no-referrer

基点の文書 移動先 使用されるリファラー
https://example.com/page すべての場所 (リファラーなし)

no-referrer-when-downgrade

基点の文書 移動先 使用されるリファラー
https://example.com/page https://example.com/otherpage https://example.com/page
https://example.com/page https://mozilla.org https://example.com/page
https://example.com/page http://example.com (リファラーなし)

origin

基点の文書 移動先 使用されるリファラー
https://example.com/page すべての場所 https://example.com/

origin-when-cross-origin

基点の文書 移動先 使用されるリファラー
https://example.com/page https://example.com/otherpage https://example.com/page
https://example.com/page https://mozilla.org https://example.com/
https://example.com/page http://example.com/page https://example.com/

same-origin

基点の文書 移動先 使用されるリファラー
https://example.com/page https://example.com/otherpage https://example.com/page
https://example.com/page https://mozilla.org (リファラーなし)

strict-origin

基点の文書 移動先 使用されるリファラー
https://example.com/page https://mozilla.org https://example.com/
https://example.com/page http://example.com (リファラーなし)
http://example.com/page すべての場所 http://example.com/

strict-origin-when-cross-origin

基点の文書 移動先 使用されるリファラー
https://example.com/page https://example.com/otherpage https://example.com/page
https://example.com/page https://mozilla.org https://example.com/
https://example.com/page http://example.com (リファラーなし)

unsafe-url

基点の文書 移動先 使用されるリファラー
https://example.com/page?q=123 すべての場所 https://example.com/page?q=123

代替ポリシーの指定

必要なポリシーのブラウザーの対応状況が十分ではなく、代替ポリシーを設定したい場合は、カンマ区切りのリストを使用し、必要なポリシーを最後に指定してください。

Referrer-Policy: no-referrer, strict-origin-when-cross-origin

上記のシナリオでは、 no-referrer はブラウザーが strict-origin-when-cross-origin に対応していない場合のみ使用されます。

メモ: 複数の値を設定する方法は、 HTTP の Referrer-Policy ヘッダーのみが対応しており、 referrerpolicy 属性では対応していません。

ブラウザー固有の設定

Firefox の設定

Firefox のユーザー設定では既定のリファラーポリシーを構成できます。設定名はバージョンにより異なります。

  • Firefox バージョン 59以降: network.http.referer.defaultPolicy (プライベートネットワークでは network.http.referer.defaultPolicy.pbmode)
  • Firefox バージョン 53 から 58: network.http.referer.userControlPolicy

どちらも 0 = no-referrer, 1 = same-origin, 2 = strict-origin-when-cross-origin, 3 = no-referrer-when-downgrade と、同じ設定値をとります。

仕様書

Specification
Referrer Policy
# referrer-policy-header

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Referrer-Policy
Default policy is strict-origin-when-cross-origin
no-referrer-when-downgrade
origin-when-cross-origin
same-origin
strict-origin
strict-origin-when-cross-origin
unsafe-url

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報