Location

The HTTP Location response header specifies the target URL for redirections and identifies the URL of a newly created resource.

Usage

Servers include Location when directing clients to a different URL. The header appears in two contexts: redirect responses and resource creation.

For Redirects, the Location value tells the client where to send the next request. The behavior depends on the status code:

  • 301 Moved Permanently and 308 Permanent Redirect indicate the resource has moved to the new URL for all future requests. A 308 preserves the original HTTP method.
  • 302 Found and 307 Temporary Redirect indicate a temporary move. A 307 preserves the original method, while 302 historically allowed method changes.
  • 303 See Other directs the client to retrieve the result at a different URL using GET, commonly used after a POST submission.

For resource creation, a 201 Created response includes Location pointing to the newly created resource. This gives the client a direct reference without requiring a follow-up search.

The Location value accepts both absolute and relative URLs. Relative URLs are resolved against the request URI.

Note

The Location header and the Content-Location header serve different purposes. Location points to the redirect target or newly created resource. Content-Location identifies the direct URL of the returned representation.

Note

Search engines follow redirects and transfer link equity (ranking value) to the target URL on permanent redirects (301, 308). Temporary redirects (302, 307) do not always pass link equity. Using the correct status code during URL migrations preserves search rankings.

Directives

URL

The value is a single URI reference pointing to the target location.

Location: <url>

The URL is either an absolute URI with scheme and host, or a relative reference resolved against the request URI.

Example

A permanent redirect from an old domain to a new one preserves the original method and tells clients to update bookmarks and links.

HTTP/1.1 301 Moved Permanently
Location: https://new.example.re/products

After creating a resource through a POST request, the server returns 201 with the Location of the new resource.

HTTP/1.1 201 Created
Location: /api/orders/7891
Content-Type: application/json

A 303 response after a form submission redirects the client to a results page using GET.

HTTP/1.1 303 See Other
Location: /search/results?q=http+headers

Takeaway

The Location header directs clients to a new URL during Redirects or points to a newly created resource in 201 responses. The associated status code determines whether the redirect is permanent, temporary, or method-changing.

See also

Last updated: March 4, 2026