HTTP 301 vs 302 Redirect: Differences and When to Use Each
301 and 302 are the two most common HTTP redirects, and even seasoned developers confuse them. The wrong choice costs SEO rankings, breaks analytics, and creates redirect loops. This article covers the fundamental difference, SEO impact, when to use each, and real setup examples for nginx, Apache, PHP, and WordPress.
What Is 301 Moved Permanently
Per RFC 9110 §15.4.2, 301 means: "this resource has moved permanently — use the new URL for all future requests." Search engines transfer ~90-99% of SEO equity from the old URL to the new one. Browsers cache the redirect aggressively.
What Is 302 Found
The 302 code (RFC 9110 §15.4.3) means: "the resource is temporarily available at a different URL, but the original URL remains authoritative." SEO equity is NOT transferred — the old URL stays indexed. Browsers do not cache.
Key Differences
| Aspect | 301 | 302 |
|---|---|---|
| Semantics | Permanent | Temporary |
| SEO equity | Transferred | Not transferred |
| Browser caching | Yes (aggressive) | No |
| Indexed URL | New URL | Old URL |
| Request method | May change to GET | May change to GET |
When to Use 301
- Domain migration (example.com → example.io)
- URL structure change (switching to clean URLs)
- HTTP → SSL/TLS проверку
- www → non-www (or vice versa)
- Removing outdated pages with a replacement target
- Changing blog post slugs
When to Use 302
- A/B testing — temporarily route part of traffic elsewhere
- Maintenance mode — redirect to a holding page
- Geo routing (edge case — 307 is usually better)
- Temporary promotions — revert to canonical after the campaign
- Authentication — post-login redirect to the originally requested page
nginx Configuration
# 301 permanent
location = /old-page {
return 301 https://example.com/new-page;
}
# 302 temporary
location = /promo {
return 302 https://example.com/black-friday;
}
# HTTP → HTTPS (always 301)
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}Apache (.htaccess)
# 301
Redirect 301 /old-page /new-page
# 302
Redirect 302 /promo /black-friday
# HTTP → HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]PHP
<?php
// 301
header('Location: https://example.com/new-page', true, 301);
exit;
// 302 (default, but be explicit)
header('Location: https://example.com/temp-page', true, 302);
exit;WordPress
Use the Redirection or Rank Math plugin, or in code:
add_action('template_redirect', function () {
if (is_page('old-page')) {
wp_redirect(home_url('/new-page'), 301);
exit;
}
});SEO Risks of Wrong Choice
- 302 instead of 301 on migration → Google does not pass equity, new URL does not rank.
- 301 for A/B testing → browsers cache it; you cannot roll back quickly.
- Redirect chains → 301 → 301 → 301 loses up to 15% equity and adds latency.
- Protocol mismatch — always verify your HTTPS chain.
Inspect redirect chains with the HTTP Header Checker by Enterno.io — it shows every hop with status codes and timing.
303, 307, 308 — When Needed
- 303 See Other — redirect after POST to a GET (POST-Redirect-Get pattern)
- 307 Temporary Redirect — like 302, but method and body are preserved
- 308 Permanent Redirect — like 301, but method and body are preserved
Frequently Asked Questions
Q: Is full SEO equity passed through 301?
A: Google officially states: "301 redirects pass full PageRank." In practice, 90-99% is observed.
Q: How many chained redirects are acceptable?
A: At most one hop. Each extra redirect = SEO loss + 100-200ms latency.
Q: How do I check which code a redirect returns?
A: curl -I https://example.com or use the Enterno.io HTTP Checker — it displays the full chain.
Q: Can I use 302 permanently?
A: You can, but it is a mistake. Google may eventually treat a persistent 302 as 301, but the behavior is unpredictable.
Conclusion
The rule is simple: 301 for permanent changes, 302 for temporary ones. 99% of production redirects should be 301. Always inspect chains via the HTTP Header Checker and avoid multi-hop redirects.
Check your website right now
Check now →