---
title: Location
slug: Web/HTTP/Headers/Location
tags:
  - HTTP
  - HTTP レスポンスヘッダー
  - リファレンス
  - レスポンスヘッダー
translation_of: Web/HTTP/Headers/Location
---
<div>{{HTTPSidebar}}</div>

<p><strong><code>Location</code></strong> レスポンスヘッダーはリダイレクト先の URL を示します。 <code>3xx</code> (リダイレクト) または <code>{{HTTPStatus("201")}}</code> (created) ステータスレスポンスを返すときのみ意味を成します。</p>

<p>リダイレクトの場合、 HTTP メソッドは元のメソッドとリダイレクトの種類によって、 <code>Location</code> で示されたページにアクセスする新しいリクエストを生成するために使用します。</p>

<ul>
 <li>{{HTTPStatus("303")}} (See Also) レスポンスは常に {{HTTPMethod("GET")}} メソッドを使用するように誘導され、 {{HTTPStatus("307")}} (Temporary Redirect) および {{HTTPStatus("308")}} (Permanent Redirect) は元のリクエストにおいて使用されたメソッドを変更しません。</li>
 <li>{{HTTPStatus("301")}} (Moved Permanently) と {{HTTPStatus("302")}} (Found) は多くの場合はメソッドを変更しませんが、古いユーザーエージェントは変更することがあります (そのため、基本的に結果は不明です)。</li>
</ul>

<p>これらのステータスコードを持つすべてのレスポンスは、 <code>Location</code> ヘッダーを送信します。</p>

<p>リソース作成 (created) では、新しく作成されたリソースへの URL を示します。</p>

<p><code>Location</code> と {{HTTPHeader("Content-Location")}} は異なります。 <code>Location</code> ヘッダーは、リダイレクトの対象 (または新しく作成されたリソースの URL) を示し、 {{HTTPHeader("Content-Location")}} ヘッダーは<a href="/ja/docs/Web/HTTP/Content_negotiation">コンテンツネゴシエーション</a>が起きたとき、更なるコンテンツネゴシエーションが起きないように、リソースへアクセスできる直接的なURLを指します。 <code>Location</code> はレスポンスに関連付くヘッダーで、 {{HTTPHeader("Content-Location")}} は返されるエンティティに関連付けられます。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">ヘッダー種別</th>
   <td>{{Glossary("Response header", "レスポンスヘッダー")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name", "禁止ヘッダー名")}}</th>
   <td>いいえ</td>
  </tr>
 </tbody>
</table>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox">Location: &lt;url&gt;
</pre>

<h2 id="Directives" name="Directives">ディレクティブ</h2>

<dl>
 <dt>&lt;url&gt;</dt>
 <dd>(リクエスト URL からの) 相対 URL、または絶対 URL。</dd>
</dl>

<h2 id="Examples" name="Examples">例</h2>

<pre>Location: /index.html</pre>

<h2 id="Specifications" name="Specifications">仕様書</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">仕様書</th>
   <th scope="col">題名</th>
  </tr>
  <tr>
   <td>{{RFC("7231", "Location", "7.1.2")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2>

<p>{{Compat("http.headers.Location")}}</p>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li>{{HTTPHeader("Content-Location")}}</li>
 <li><code>Location</code> ヘッダーを含むレスポンスのステータス: {{HTTPStatus("201")}}, {{HTTPStatus("301")}}, {{HTTPStatus("302")}}, {{HTTPStatus("303")}}, {{HTTPStatus("307")}}, {{HTTPStatus("308")}}.</li>
</ul>