Both 301 and 302 are HTTP redirect status codes, but they differ in meaning and use case.
-
Meaning: The resource has been permanently moved to a new URL.
-
Effect on browsers & SEO:
- Browsers (and clients) cache the redirect.
- Search engines update their index to the new URL.
- Any "link juice" (SEO ranking) is passed to the new URL.
-
Use case:
-
When a page/endpoint is permanently moved.
-
Example:
GET /old-page → 301 Moved Permanently → Location: /new-pageNow future requests will directly go to
/new-page.
-
-
Meaning: The resource has been temporarily moved to a different URL.
-
Effect on browsers & SEO:
- Browsers do not cache permanently.
- Search engines do not update their index (they keep old URL).
- Link authority usually stays with the old URL.
-
Use case:
-
When you want to redirect temporarily, but keep the original URL as the main one.
-
Example: A product page
/product/123is temporarily out of stock →GET /product/123 → 302 Found → Location: /unavailable
-
- 301: Permanent → use when the resource has moved forever.
- 302: Temporary → use when the move is just for a short time.
👉 Bonus: There are also 307 Temporary Redirect and 308 Permanent Redirect which are stricter versions of 302/301 (they preserve the HTTP method, e.g., POST stays POST).