The HTTP Location response header is used to specify the target URL when a page redirect occurs.
The Location response header is used to provide the destination URL when the client receives a HTTP response that includes redirection. The interpretation of the HTTP Location header depends on the HTTP method that was originally used. Several HTTP response status codes will automatically include the HTTP Location header. These include redirection responses, as well as HTTP 201 Created.
The HTTP Location header can specify either a relative or absolute URL.
When a new resource is created and HTTP status 201 Created is returned, the HTTP Location header will point to the new resource.
There is a difference between the HTTP Location header and HTTP Content-Location header. The former indicates the URL of the newly created resource, whereas Content-Location contains the direct URL that is used during the Content Negotiation phase. Specifically, Location is related to the HTTP response, and Content-Location is related to the entity that was returned to the client.
In the example, the server responds to the HTTP GET request to the origin of example.re with the 302 Found redirect status code and a new URL in the HTTP Location header for the client to request next:
HTTP/1.1 302 Found Location: https://example.re/
The HTTP Location header is used to inform the client of where to find the resource either after a redirection or the creation of new content.