Contents
HTTP location
The HTTP Location header field is returned in responses from an HTTP server under two circumstances: An obsolete version of the HTTP 1.1 specifications (IETF RFC 2616) required a complete absolute URI for redirection. The IETF HTTP working group found that the most popular web browsers tolerate the passing of a relative URL and, consequently, the updated HTTP 1.1 specifications (IETF RFC 7231) relaxed the original constraint, allowing the use of relative URLs in Location headers.
Examples
Absolute URL example
Absolute URLs are URLs that start with a scheme (e.g., http:, https:, telnet:, mailto: ) and conform 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". A client requesting https://www.example.com/index.html using may get the server response
Relative URL absolute path example
Relative URLs are URLs that do not include a scheme or a host. In order to be understood they must be combined with the URL of the original request. A client request for https://www.example.com/blog/all may get a server response with a path that is absolute because it starts with a slash: The URL of the location is expanded by the client to https://www.example.com/articles/.
Relative URL relative path example
A client request for https://www.example.com/blog/latest may get a server response with a path that is relative because it doesn't start with a slash: The client removes the path segment after the last slash of the original URL and appends the relative path resulting in https://www.example.com/blog/2020/zoo.
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.