general

Location

In 3xx redirects, tells the client where to go next; in 201 Created, points at the newly created resource. Per RFC 9110 the value may be a relative reference resolved against the request URL.

Location: <URI-reference>  (absolute URL or absolute-path reference)

Common directives / values

Directive Purpose
absolute URL e.g. https://example.com/new — always unambiguous.
absolute-path reference e.g. /login — resolved against the current origin.
relative reference Legal since RFC 7231/9110; some old clients still expect absolute.

Examples

HTTP/1.1 302 Found\nLocation: /login

Send unauthenticated users to the login page.

HTTP/1.1 201 Created\nLocation: /users/42

REST create — point the client at the new resource.

HTTP/1.1 301 Moved Permanently\nLocation: https://www.example.com/new

Permanent redirect to a canonical URL — SEO-friendly.

HTTP/1.1 307 Temporary Redirect\nLocation: https://api.example.com/v2/

Preserves method and body across the redirect (unlike 302).

Gotcha

302/303 change POST to GET on redirect; 307/308 preserve the method — pick the right code or clients lose the body. To read Location on 201 from cross-origin JS, list it in Access-Control-Expose-Headers.

Related headers

← All HTTP headers · HTTP status codes · Fix CORS errors