Location
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 Other
responses always result in aGET
request in the redirection.307 Temporary Redirect
and308 Permanent Redirect
use the same method as the initiating request.301 Moved Permanently
and302 Found
should 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 header name | 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
BCD tables only load in the browser