302 Found
Redirect - Resource temporarily at different URL
HTTP 302 Found
What It Means
The HTTP 302 Found status code indicates that the requested resource temporarily resides at a different URL. Unlike 301, the client should continue using the original URL for future requests.
When to Use 302
- A/B testing: Redirecting users to different page variants
- Maintenance pages: Temporarily showing a maintenance page
- Geolocation: Redirecting based on user location
- Login redirects: Sending users to login before accessing content
- Cart/checkout: Redirecting after adding to cart
Example Response
HTTP/1.1 302 Found
Location: https://example.com/temporary-page
Cache-Control: no-cache
<html>
<body>
Redirecting to
<a href="https://example.com/temporary-page">here</a>...
</body>
</html>
302 vs 301: Key Differences
| Aspect | 301 | 302 |
|---|---|---|
| Duration | Permanent | Temporary |
| Browser caching | Cached indefinitely | Not cached by default |
| SEO value | Transferred to new URL | Stays with original URL |
| Search indexing | New URL indexed | Original URL stays indexed |
302 vs 307
302 may change POST to GET during redirect (historical browser behavior).
307 preserves the HTTP method. If you need to redirect a POST and maintain the method, use 307.
Implementation Examples
Express.js
app.get('/promo', (req, res) => {
res.redirect(302, '/current-sale');
});
Python Flask
from flask import redirect
@app.route('/promo')
def promo():
return redirect('/current-sale', code=302)
PHP
header('Location: /current-sale', true, 302);
exit;
Common Mistakes
- Using 302 for permanent moves: Hurts SEO, use 301
- Redirect loops: Check that target doesn't redirect back
- Missing Location header: Required for all 3xx redirects