- HTTP
- SEO
- Backend
- Guide
301 vs 302 Redirects: Which One to Use
When to use a 301 or 302 redirect, which URL Google shows in search for each, and how 307 and 308 keep POST requests intact.
Use a 301 redirect when a URL has moved for good, and a 302 when the move is temporary and the original URL will come back. For search engines, the key difference is which URL appears in results: Google shows the new target for a permanent redirect and keeps showing the original source page for a temporary one.
Key takeaways
- 301 (Moved Permanently) is for permanent moves such as domain changes, HTTPS migrations and merged pages. Google uses it as a signal that the target should be canonical.
- 302 (Found) is for temporary moves such as maintenance pages or short promotions. Google keeps showing the source URL in results.
- Choose based on intent: how long the move will last and which URL you want people to find in search.
- 308 and 307 are the permanent and temporary equivalents that guarantee the request method and body are not changed.
- Browsers can cache permanent redirects, so test a 301 before you deploy it.
What an HTTP redirect is
A redirect is a response with a status code in the 3xx range and a Location header. It tells the client, "The resource you asked for is at this other URL." Browsers follow it automatically, and search engine crawlers use it to decide which URL to index. MDN's guide to HTTP redirections covers every redirect type in detail.
301: Moved Permanently
A 301 redirect says the resource has moved permanently and clients should use the new URL from now on.
How a 301 affects SEO
According to Google Search Central's redirects documentation, Googlebot follows a permanent redirect, and the indexing pipeline uses it as a signal that the redirect target should be canonical. The new URL is then shown in search results. Google's guide to consolidating duplicate URLs lists redirects as "a strong signal that the target of the redirect should become canonical".
When to use 301
- Site migrations: moving from
example.comtonew-example.com. - Protocol changes: redirecting all
http://traffic tohttps://. - Host consolidation: choosing between
www.example.comandexample.com. - Content cleanup: sending an old, deleted post to its closest replacement.
For site moves, Google's site move guidance advises keeping redirects "for as long as possible, generally at least 1 year".
The caching risk
Browsers may cache a 301 and send users straight to the target without asking your server again. If you mistakenly redirect /login to /error with a 301, fixing the server won't help visitors who already have the redirect cached until their cache is cleared. Test permanent redirects on a staging environment first.
302: Found (temporary redirect)
A 302 redirect says the resource is temporarily available at another URL and clients should keep using the original one.
How a 302 affects SEO
Google's redirects documentation says temporary redirects show the source page in search results. In other words, Google keeps treating the original URL as the one to show, which is exactly what you want when the page is coming back. If a move turns out to be permanent after all, switch to a 301 so your intent is clear.
When to use 302
- Maintenance: sending visitors to a status page while a section is being updated. For a site-wide outage, a
503 Service Unavailableresponse is often a better choice. - Short promotions: pointing
/saleat this week's landing page. - Locale or device routing: sending a visitor from
example.comtoexample.com/fr/whileexample.comremains the main URL. - A/B tests: splitting traffic between variants without replacing the original URL.
307 and 308: method-preserving redirects
With 301 and 302, browsers may change a POST request into a GET when following the redirect, which drops the request body. MDN notes that the specification didn't intend this, but existing user agents do it anyway. Two newer codes remove the ambiguity:
- 307 Temporary Redirect: like 302, but the method and body must not change.
- 308 Permanent Redirect: like 301, but the method and body must not change.
Google's documentation groups 308 with 301 as permanent redirects, and 307 with 302 (and 303) as temporary ones. For ordinary page navigation, which uses GET requests, 301 and 302 are fine. Use 307 or 308 when a redirected request might be a POST, PUT or DELETE, such as an API endpoint that has moved.
Summary checklist
| Scenario | Recommended redirect | Why |
|---|---|---|
| Moving to a new domain | 301 (or 308) | The new URL should become canonical. |
| HTTP to HTTPS | 301 (or 308) | Permanent change of protocol. |
| Seasonal sale page | 302 (or 307) | The original URL should stay in results. |
| Temporary maintenance | 302, or 503 for outages | Temporary state. |
| API endpoint moved permanently | 308 | Preserves POST bodies. |
Implementing redirects in Express.js
Passing the status code explicitly makes your intent obvious to anyone reading the code:
const express = require('express');
const app = express();
// Permanent move
app.get('/old-blog', (req, res) => {
res.redirect(301, '/new-blog');
});
// Temporary move
app.get('/promo', (req, res) => {
res.redirect(302, '/current-promo');
});
// Permanent move that keeps POST bodies intact
app.post('/api/v1/orders', (req, res) => {
res.redirect(308, '/api/v2/orders');
});
app.listen(3000);
Express needs a real Node.js process to run, so test this locally. The WebFiddle Node.js sandbox runs in a Web Worker and can't load packages like Express, but it's handy for trying out the URL and string logic behind redirect rules. For related technical SEO reading, see our guide to semantic HTML for SEO.
Frequently asked questions
Which redirect does Google show in search results?
Google's documentation says that for a permanent redirect, such as 301 or 308, the new redirect target is shown in search results. For a temporary redirect, such as 302, 303 or 307, Google shows the original source page instead. Pick the status code that matches the URL you want people to find.
When should I use a 301 instead of a 302?
Use a 301 when the old URL will not come back, for example after a domain move, an HTTPS migration or permanently merging two pages. Use a 302 when the original URL will return, such as during maintenance or a short promotion. If you are unsure whether a change is permanent, a 302 is easier to undo.
What is the difference between 307 and 302?
Both are temporary redirects. With a 302, browsers may change a POST request into a GET and drop its body. A 307 guarantees that the method and body stay the same, which matters for forms and APIs. Google groups 307 with 302 as temporary redirects, so either works for ordinary pages.
How long should I keep a 301 redirect in place?
Keep it as long as possible. Google's site move guidance recommends keeping redirects for generally at least one year, and longer is better for users, so returning visitors, bookmarks and external links keep working. Removing a redirect early turns every old link into a 404 error for anyone who still follows it.
Can I undo a 301 redirect?
You can change the server rule at any time, but browsers that cached the permanent redirect may keep sending users to the old target until their cache expires or is cleared. Search engines will pick up the change when they recrawl. That is why permanent redirects should be tested before going live.
WebFiddle