HTTP Redirect Codes
Deep-dive on 301, 302, 303, 307, 308 — differences, use cases, SEO implications, browser caching behavior, and common mistakes.
| Code | Name | Permanent? | Method preserved? | Browser-cached? | SEO equity passed? |
|---|---|---|---|---|---|
| 301 | Moved Permanently | Yes | No (→ GET) | Yes | Yes |
| 302 | Found | No | No (→ GET) | Sometimes | Partial |
| 303 | See Other | No | Always GET | No | No |
| 307 | Temporary Redirect | No | Yes | No | Partial |
| 308 | Permanent Redirect | Yes | Yes | Yes | Yes |
- Migrating a site to a new domain (example.com → newdomain.com)
- Consolidating www/non-www to a canonical version
- Permanently restructuring URL paths (/old-path → /new-path)
- Redirecting HTTP to HTTPS (though 308 preserves method)
- Using 301 for temporary A/B tests — the redirect gets cached and is hard to undo
- Forgetting that browsers cache 301s aggressively; clearing requires cache busting or user action
- Using 301 for POST-redirect-GET flows — use 303 instead
HTTP/1.1 301 Moved Permanently Location: https://www.example.com/new-path Cache-Control: max-age=31536000
- Maintenance pages where the site will return to the original URL
- Login walls — redirect to /login, then back after auth
- Feature flags routing users to different pages temporarily
- Using 302 when you mean 301 — search engines won't pass link equity
- Relying on 302 to preserve POST method — use 307 for that
- Long-lived 302s that should have been 301s from the start
- Post/Redirect/Get (PRG) — form submission → confirmation page
- After creating a resource via POST, redirect to the new resource
- OAuth callbacks — after POST auth, redirect to the app as GET
POST /submit-order → 303 See Other Location: /order/12345/confirmation GET /order/12345/confirmation ← 200 OK
- API endpoints that temporarily move — preserve PUT/POST/DELETE body
- Temporary HTTP → HTTPS redirect where the POST body must survive
- Load balancer failover to a backup server, same method required
- Confusing 307 with 302 — they look similar but 307 strictly preserves method
- Using 307 for PRG (post-redirect-get) — use 303 so the browser issues GET
- Permanent HTTP → HTTPS migration where POST bodies must not be lost
- Permanent API endpoint moves where method matters (REST APIs)
- Domain migrations for services that accept non-GET requests
- Using 308 without testing in older browsers — IE11 does not support it
- Forgetting that 308 is cached permanently — same caveats as 301