Skip to content

Location

Indicates the destination URL when redirecting a browser or creating a new resource.

The Location response HTTP header provides the URL to which an entity or a browser should be redirected. It is the core mechanism driving HTTP redirects on the web.

It is universally used in two scenarios: First, when returning a 3xx status code (like 301 Moved Permanently or 302 Found) to redirect the user to a new web page. Second, when responding with a 201 Created to indicate the URL of a newly minted REST API resource.

Without the Location header, returning a 302 status code does nothing; the browser needs to know precisely where to go. On 201 Created responses, it saves the client from having to guess the ID or URL of the newly created object.

Simply provide the absolute or relative URL. Location: /dashboard Location: https://new-domain.com/login

Location: https://example.com/login