Redirects inform clients that a resource has moved.
The choice of status code affects method handling, cache persistence, and search engine behaviour.
Redirect Decision Flow
flowchart TD
A[Is the move permanent?] -->|Yes| B[Must the HTTP method be preserved?]
A -->|No| C[Must the HTTP method be preserved?]
B -->|Yes| D[308 Permanent Redirect]
B -->|No| E[301 Moved Permanently]
C -->|Yes| F[307 Temporary Redirect]
C -->|No| G[302 Found]
%% Contextual hints
D:::perm --> H[Set long TTL; expect SEO consolidation]
E:::perm --> H
F:::temp --> I[Short TTL; use for maintenance]
G:::temp --> I
classDef perm fill:#ddd,stroke:#333,color:#000;
classDef temp fill:#eee,stroke:#333,color:#000;
Overview Table
Code | Meaning | Method Preserved | Cacheable by Default | SEO Signal |
---|---|---|---|---|
301 | Permanent redirect | Not guaranteed | Yes | Passes link equity |
302 | Temporary redirect (legacy) | Not guaranteed | No | Limited |
307 | Temporary, method preserved | Yes | No | Limited |
308 | Permanent, method preserved | Yes | Yes | Passes link equity |
301 Moved Permanently
Permanent relocation. Clients may update bookmarks.
Caching: Long-lived; set deliberate TTL.
302 Found
Temporary. Historical clients may change POST to GET.
CDN note: Avoid if method preservation is needed.
307 Temporary Redirect
Temporary and preserves method/body. Good for maintenance windows.
308 Permanent Redirect
Permanent and preserves method/body. Prefer over 301 for non-GET methods.
Choosing the Right Redirect
- Permanent: 301 (legacy) or 308 (method-preserving).
- Temporary: 302 (legacy) or 307 (method-preserving).
- Prefer 307/308 when redirecting non-GET requests.
CDN & SEO Considerations
- Long-lived redirects can be cached at edge and client.
- Search engines eventually consolidate signals for 301/308.
- Minimise chains; avoid multiple hops.