-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
82 lines (62 loc) · 2.29 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: Location
slug: Web/HTTP/Headers/Location
page-type: http-header
browser-compat: http.headers.Location
---
{{HTTPSidebar}}
The **`Location`** response header indicates the URL to
redirect a page to. It only provides a meaning when served with a
`3xx` (redirection) or `201` (created) status response.
In cases of redirection, the HTTP method used to make the new request to fetch the page
pointed to by `Location` depends on the original method and the kind of
redirection:
- {{HTTPStatus("303")}} (See Other) responses always lead to the use of a
{{HTTPMethod("GET")}} method.
- {{HTTPStatus("307")}} (Temporary Redirect) and
{{HTTPStatus("308")}} (Permanent Redirect) don't change the method used in the
original request.
- {{HTTPStatus("301")}} (Moved Permanently) and {{HTTPStatus("302")}} (Found) don't
change the method most of the time, though older user-agents may (so you basically
don't know).
All responses with one of these status codes send a `Location` header.
In cases of resource creation, it indicates the URL to the newly created resource.
`Location` and {{HTTPHeader("Content-Location")}} are different.
`Location` indicates the target of a redirection or the URL of a newly
created resource. {{HTTPHeader("Content-Location")}} indicates the direct URL to
use to access the resource when [content negotiation](/en-US/docs/Web/HTTP/Content_negotiation) happened,
without the need of further content negotiation. `Location` is a header
associated with the response, while {{HTTPHeader("Content-Location")}} is associated
with the entity returned.
<table class="properties">
<tbody>
<tr>
<th scope="row">Header type</th>
<td>{{Glossary("Response header")}}</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
</tr>
</tbody>
</table>
## Syntax
```http
Location: <url>
```
## Directives
- \<url>
- : A relative (to the request URL) or absolute URL.
## Examples
```http
Location: /index.html
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{HTTPHeader("Content-Location")}}
- Status of responses including a `Location` header: {{HTTPStatus("201")}},
{{HTTPStatus("301")}}, {{HTTPStatus("302")}}, {{HTTPStatus("303")}},
{{HTTPStatus("307")}}, {{HTTPStatus("308")}}.