Both 301 and 302 are HTTP redirect status codes, but they differ in meaning and use case.
πΉ 301 Moved Permanently
- 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.
πΉ 302 Found (Temporary Redirect)
- 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
βοΈ Key Difference
- 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).