Location Header Explained
What the HTTP Location header does and when it's used.
Published October 16, 2026
Location tells the client where to go next: the target of a redirect (3xx) or the URL of a newly created resource (201).
How it works
It can be absolute or relative.
The Location header is part of the HTTP message and is case-insensitive in name.
In a real exchange
curl -i https://example.com/
Location: https://example.com/new-page
Practical examples
The header
Location: https://example.com/new-pageSet or use it in code
res.redirect(301, '/new-page')Inspect it
curl -sI https://example.com | grep -i 'location'Common mistakes
- Redirect chains
- Relative URLs miscomputed behind proxies
- Open redirects from unvalidated user input
Key takeaways
- Location: Location tells the client where to go next: the target of a redirect (3xx) or the URL of a newly created resource (201).
- Check it in browser DevTools → Network.
- Test with curl -I before deploying.
FAQ
Absolute or relative?
Both are allowed; absolute is safest.
Is Location case sensitive?
Header names are case-insensitive; values may not be.