HTTP location
Encyclopedia
The HTTP Location header is returned in responses from an HTTP server under two circumstances:
1. To ask a web browser to load a different web page. It is passed as part of the response by a web server when the requested URI
has:
In this circumstance, the HTTP Location header should be sent with an HTTP status code of 3xx.
2. To provide information about the location of a newly-created resource.
In this circumstance, the HTTP Location header should be sent with an HTTP status code of 201.
While the internet standard RFC 1945 (HTTP 1.0) requires a complete absolute URI for redirection, the most popular web browsers support the passing of a Relative URL as the value for a Location: header.
http:, https:, telnet:, mailto: ) and conforms to scheme-specific syntax and semantics. For example, the HTTP scheme-specific syntax and semantics for HTTP URLs requires a "host" (web server address) and "absolute path", with optional components of "port" and "query". In the case that there is no absolute path present, it must be given as "/" when used as a Request-URI for a resource.
Client request:
Server response:
Client request:
Server response:
1. To ask a web browser to load a different web page. It is passed as part of the response by a web server when the requested URI
Úri
Úriis a village and commune in the comitatus of Pest in Hungary....
has:
- Moved temporarily, or
- Moved permanently
In this circumstance, the HTTP Location header should be sent with an HTTP status code of 3xx.
2. To provide information about the location of a newly-created resource.
In this circumstance, the HTTP Location header should be sent with an HTTP status code of 201.
While the internet standard RFC 1945 (HTTP 1.0) requires a complete absolute URI for redirection, the most popular web browsers support the passing of a Relative URL as the value for a Location: header.
Example
The internet standard requires an absoluteURI token to follow a Location: header, which means it must contain a scheme (e.g.,Client request:
GET /index.html HTTP/1.1
Host: www.example.com
Server response:
HTTP/1.1 302 Found
Location: http://www.example.org/index.php
Relative URL Example
This example, while incorrect based on the internet standard, will often work in popular browsers.Client request:
GET /blog HTTP/1.1
Host: www.example.com
Server response:
HTTP/1.1 302 Found
Location: /blog/