Location header
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The HTTP Location response header indicates the URL to redirect a page to.
It only provides a meaning when served with a 3XX redirection response or a 201 Created status response.
In redirections, the HTTP method used to make the redirected request to fetch the page pointed to by Location depends on the original method and the kind of redirection:
303 See Otherresponses always result in aGETrequest in the redirection.307 Temporary Redirectand308 Permanent Redirectuse the same method as the initiating request.301 Moved Permanentlyand302 Foundshould use the same request method as the initiating request, although this is not guaranteed for older user-agents.
All responses with one of the above status codes include a Location header.
In cases of resource creation, it indicates the URL of the newly-created resource so that a client can make a request for it immediately.
Location and Content-Location are different.
Content-Location indicates the URL to use to directly access the resource in future when content negotiation occurred.
Location is associated with the response, while Content-Location is associated with the representation that was returned.
| Header type | Response header |
|---|---|
| Forbidden request header | No |
Syntax
Location: <url>
Directives
<url>-
May be relative to the request URL or an absolute URL.
Examples
Location: /index.html
Specifications
| Specification |
|---|
| HTTP Semantics> # field.location> |
Browser compatibility
Loading…