An HTTP redirect is a 3xx response with a Location header that sends the client to a different URL. A 301 Moved Permanently says the resource has moved for good; a 302 Found says the move is temporary and the original URL should still be used later.
Why it matters
Browsers cache 301s aggressively, and search engines treat them as a signal to consolidate to the new URL. A 302 keeps the old URL as the canonical one. Choosing wrongly can leave the wrong page indexed or trap users on an old cached redirect. Chains and loops add latency and can cause ERR_TOO_MANY_REDIRECTS.
Example
HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/pricing
For methods other than GET, the older codes allow clients to change a POST into a GET. 307 (temporary) and 308 (permanent) preserve the method and body, so use them for API redirects.
return 301 https://www.example.com$request_uri;
Common mistakes
- Redirecting everything to the homepage instead of the equivalent page.
- Building chains such as
httptohttpstowwwto a new path. Redirect straight to the final URL. - Testing a 301 in your browser, which has cached it, and not in a clean client such as
curl -I. - Using a permanent redirect for a short-term campaign page.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.