HTTP 301 vs 302 Redirects — Permanent vs Temporary
About HTTP 301 vs 302 Redirects
HTTP 301 is a permanent redirect and 302 is a temporary redirect. Choosing the wrong one impacts SEO, caching, and user experience. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: 301 Moved Permanently — the resource has a new permanent URL. 302 Found — the resource is temporarily at a different URL. 301 passes SEO link equity to the new URL, 302 does not. Browsers cache 301 redirects aggressively, 302 redirects are re-checked. Search engines update their index for 301 but keep the original URL for 302. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Website migrated to a new domain (use 301). Page moved to a new URL path permanently (use 301). A/B testing sending users to alternate pages temporarily (use 302). Maintenance page redirect while the real page is updated (use 302). Login redirect to authentication page (use 302). Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Use 301 for permanent URL changes: domain migrations, URL restructuring. Use 302 for temporary redirects: A/B tests, maintenance, login flows. In nginx: return 301 https://new-url (permanent) or return 302 https://temp-url (temporary). In Apache: Redirect 301 /old-path https://new-url or Redirect 302 /old-path https://temp-url. Test redirects with curl -I URL to verify the status code. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Which redirect is better for SEO?
301 for permanent changes. It tells search engines to transfer ranking signals to the new URL. Using 302 for permanent moves wastes SEO equity.
Overview
HTTP 301 is a permanent redirect and 302 is a temporary redirect. Choosing the wrong one impacts SEO, caching, and user experience.
Key Details
- 301 Moved Permanently — the resource has a new permanent URL
- 302 Found — the resource is temporarily at a different URL
- 301 passes SEO link equity to the new URL, 302 does not
- Browsers cache 301 redirects aggressively, 302 redirects are re-checked
- Search engines update their index for 301 but keep the original URL for 302
Common Causes
- Website migrated to a new domain (use 301)
- Page moved to a new URL path permanently (use 301)
- A/B testing sending users to alternate pages temporarily (use 302)
- Maintenance page redirect while the real page is updated (use 302)
- Login redirect to authentication page (use 302)
Steps
- 1Use 301 for permanent URL changes: domain migrations, URL restructuring
- 2Use 302 for temporary redirects: A/B tests, maintenance, login flows
- 3In nginx: return 301 https://new-url (permanent) or return 302 https://temp-url (temporary)
- 4In Apache: Redirect 301 /old-path https://new-url or Redirect 302 /old-path https://temp-url
- 5Test redirects with curl -I URL to verify the status code