301 vs 302 Redirects: Which One Should You Use?
By Urlzee Team · Published · 6 min read
Use a 301 when a URL has moved for good and you want browsers and search engines to forget the old address. Use a 302 when the move is temporary, or when you need every request to keep coming through the original URL, for example to count clicks or to change the destination later.
What do 301 and 302 actually mean?
Both are HTTP responses that say "the thing you asked for is somewhere else" and give the new address in a Location header. The difference is the promise attached.
- 301 Moved Permanently says the resource has a new permanent URL and future requests should go there directly.
- 302 Found says the resource is temporarily at a different URL, and the client should keep using the original one next time.
On the wire they look almost identical:
HTTP/1.1 301 Moved Permanently
Location: https://example.com/new-page
HTTP/1.1 302 Found
Location: https://example.com/new-page
A visitor cannot see any difference. The browser follows the Location header in both cases. What changes is how clients, caches and crawlers behave afterwards.
How do 301 and 302 compare side by side?
| 301 Moved Permanently | 302 Found | |
|---|---|---|
| Meaning | New address is permanent | New address is temporary |
| Cached by default | Yes, browsers may store it without being told to | No, unless caching headers say so |
| Repeat visits | Browser may skip the old URL entirely | Browser asks the old URL every time |
| Search engines | Strong signal that the target is the canonical URL | Weak signal; original URL tends to stay indexed |
| Easy to reverse | No, cached copies linger | Yes |
| Typical use | Domain change, HTTP to HTTPS, renamed page | A/B test, maintenance page, short links, geo or login redirects |
The caching row is the one that causes surprises. Under the HTTP specification, a 301 response is cacheable by default, while a 302 is only cacheable when the response includes explicit freshness information such as Cache-Control: max-age. In practice that means a browser that has seen a 301 for a URL may not contact your server about that URL again for a long time.
Which redirect is better for SEO?
Neither is "better". Each tells search engines something different, and the right one is the one that is true.
Google's documentation describes permanent redirects as a strong signal that the redirect target should be the canonical URL shown in results, and temporary redirects as a weak signal. Google follows both types. So:
- If you have moved a page and want the new URL to rank in place of the old one, a 301 (or 308) says so clearly.
- If the original URL should remain the one in search results, such as a product page temporarily sent to a "back soon" notice, a 302 (or 307) is correct.
The practical risk is using a 302 for a permanent move and leaving it for years. Search engines may eventually treat a long-lived temporary redirect as permanent, but you are leaving the decision to them. Say what you mean. Google's own guidance is in Redirects and Google Search.
For how this applies to short links in particular, see do short links hurt SEO?.
Why do URL shorteners use 302?
Because a shortener's job depends on seeing every click. If a short link answered with a cacheable 301, a returning visitor's browser could jump straight to the destination without contacting the shortener. Two things would break:
- Click counts would be too low. Repeat visits served from the browser's cache never reach the server, so they are never counted.
- Edited destinations would not take effect. If the owner changes where the link points, browsers holding the old 301 keep sending people to the old place.
Urlzee answers every short link with a 302, and also sends Cache-Control: private, no-store so nothing in between holds on to the response. That is what makes link analytics accurate and lets an edited destination apply to the very next click.
The trade-off is small: each visit makes one extra request to the shortener. For a link shared in a message or printed in a QR code, that cost is negligible. For links inside your own site, do not use a shortener at all; link straight to the page.
When should you use 307 or 308 instead?
Use them when the request method matters. 301 and 302 date from the early web, and browsers have long handled them by turning a redirected POST into a GET. The specification allows this for historical reasons. If a form submission or API call hits a 301 or 302, the body can be dropped on the way to the new URL.
Two newer codes close that gap:
| Code | Lifetime | Method and body |
|---|---|---|
| 301 Moved Permanently | Permanent | May change POST to GET |
| 308 Permanent Redirect | Permanent | Always preserved |
| 302 Found | Temporary | May change POST to GET |
| 307 Temporary Redirect | Temporary | Always preserved |
| 303 See Other | Not a move | Always switches to GET |
Rules of thumb:
- Pages people visit in a browser: 301 and 302 are fine and universally understood.
- API endpoints that accept POST, PUT or PATCH: use 308 for a permanent move and 307 for a temporary one, so clients resend the body.
- After a form submission: respond with 303 to send the browser to a results page with a GET. This prevents a refresh from submitting the form twice.
The full list of codes is in the HTTP status codes guide.
How do you check which redirect a URL returns?
Ask the server and read the status line. With curl:
curl -s -o /dev/null -D - https://example.com/old-page
-D - prints the response headers, and -o /dev/null discards the body. The first line shows the status code and the location header shows where it points. Without -L, curl does not follow the redirect, so you see exactly what the first server said.
To see a whole chain:
curl -s -o /dev/null -L -w '%{num_redirects} redirects, final: %{url_effective}\n' https://example.com/old-page
More recipes are in how to test redirects with curl. If you would rather not use a terminal, the link checker shows each hop's status code and the final URL in the browser.
One warning about testing in a browser: because 301s are cached, your browser may keep showing an old redirect after you have fixed the server. Test with curl or a private window before concluding that a change did not work.
What mistakes should you avoid?
- Using 301 while you are still experimenting. A cached permanent redirect is hard to take back. Start with a 302, confirm everything works, then switch to 301.
- Redirecting everything to the homepage. When a page is removed, redirect to its closest replacement. If there is none, return 404 or 410 so the answer is honest.
- Chaining redirects.
http://tohttps://towwwto a new path is three round trips where one would do. Point each old URL directly at the final address. See redirect chains. - Mixing signals. A 301 to page B while the canonical tag on B points back to A leaves search engines to guess.
- Forgetting internal links. After a permanent move, update links on your own site to the new URL instead of relying on the redirect forever.
Choose the code that describes reality: permanent when the old URL is retired, temporary when it is not, and the method-preserving pair when the request carries a body.
Frequently asked questions
- What is the difference between a 301 and a 302 redirect?
- A 301 tells browsers and search engines the page has moved permanently, so they can cache the new address and treat it as the real one. A 302 says the move is temporary, so clients keep asking the original URL each time.
- Is a 301 or 302 redirect better for SEO?
- Use a 301 when a page has permanently moved and you want the new URL to replace the old one in search results. Use a 302 when the original URL should stay indexed. Google follows both; the status code is a signal about which URL to treat as canonical.
- Why do URL shorteners use 302 redirects?
- A 302 is not cached by default, so every click reaches the shortener. That keeps click counts accurate and means a changed destination takes effect straight away. Urlzee uses 302 for these reasons.
- How do I undo a 301 redirect that was a mistake?
- Remove or change the rule on the server, then expect a delay: browsers that already cached the 301 may keep using it until their cache is cleared or expires. Search engines pick up the change when they next crawl the old URL.
- What are 307 and 308 redirects?
- They are the strict versions of 302 and 301. A 307 is temporary and a 308 is permanent, and both guarantee the request method and body are kept, so a POST stays a POST.