Learn when to use a permanent 301 or a temporary 302 redirect, where accidental 302s usually come from, and how the 307 and 308 codes fit in.
A redirect is a short reply from your server that says "this page is somewhere else" and gives the new address. Visitors rarely notice it happen. Search engines notice it closely, because the type of redirect tells them whether the change is permanent or temporary, and that decides which URL they keep in their index.
Most of the time the choice is between two status codes, 301 and 302. Picking the wrong one rarely breaks a site outright, but it can leave search engines holding on to the wrong address for longer than you would like.
What the numbers mean
Every response a web server sends starts with a three digit status code. Codes in the 300 range are redirects, and each one comes with a Location header holding the new address. The two you will meet most are:
- 301 Moved Permanently: the page has moved for good. Use the new address from now on.
- 302 Found: the page is temporarily available somewhere else. Keep using the original address.
Google's documentation describes a permanent redirect as a strong signal that the target URL should be treated as the canonical one, meaning the version that appears in search results. A temporary redirect is a weak signal of that, so the original URL is more likely to stay in the index.
When a 301 is right
Use a 301 whenever the old address is not coming back. Typical cases:
- A page has a new URL after a redesign or a change of platform.
- Two similar pages have been merged into one.
- The whole site has moved to https, or settled on www or non-www.
- A product or service has been replaced by a newer equivalent.
In each case you want search engines to forget the old URL and credit the new one, and a 301 says exactly that. For a full site move, a 301 on every changed URL is the foundation of the whole plan, as covered in planning a website move without losing search traffic.
When a 302 is right
A 302 is for situations where the original address will be used again. For example:
- A page is being rebuilt and visitors are sent to a holding page for a few days.
- You are testing a new version of a page against the old one. Google's guidance on site testing recommends a temporary redirect for this, so the original stays indexed.
- Visitors who are not logged in are sent to a login page before reaching an account area.
The test is simple: if you expect the original URL to be the real address again, use a 302. If you do not, use a 301. A 302 left in place for a move that turned out to be permanent is one of the most common redirect mistakes, and it is usually an accident rather than a choice.
Where accidental 302s come from
Several common tools default to a temporary redirect unless you say otherwise. On Apache, a plain Redirect line with no status sends a 302, and a RewriteRule with the [R] flag also sends a 302 unless you write [R=301]:
Redirect /old-page /new-page/
Redirect 301 /old-page /new-page/
RewriteRule ^old-page/?$ /new-page/ [R,L]
RewriteRule ^old-page/?$ /new-page/ [R=301,L]
The first line of each pair is temporary and the second is permanent. On nginx, return 302 and rewrite ... redirect are temporary, while return 301 and rewrite ... permanent are permanent. Some CMS redirect plugins also offer 302 as their first option in a drop-down. Whatever you use, check the status code it actually sends rather than trusting the label.
There is one caution in the other direction. Browsers can cache a 301 and keep following it without asking your server again. If you set a permanent redirect by mistake, some visitors may keep being sent to the wrong place after you remove it. For a rule you are unsure about, testing with a 302 first and switching to 301 once it is confirmed is a sensible habit.
A brief note on 307 and 308
Two newer codes do the same jobs with one extra guarantee. A 307 Temporary Redirect and a 308 Permanent Redirect tell the browser it must repeat the request using the same method. That matters for form submissions: with a 301 or 302, browsers may turn a POST (sending form data) into a GET (simply fetching a page) when they follow the redirect. With 307 and 308 they must not.
For ordinary page redirects this makes no practical difference. Google treats 308 like 301 and 307 like 302 for indexing. You will often see a 307 in browser developer tools on sites that use HSTS, a setting that makes the browser switch to https itself before any request reaches the server. That one is generated by the browser, not your server.
Check what your redirects really send
Because defaults and labels can mislead, the only reliable answer is to look at the response. Paste your old URLs into the bulk redirect checker and it will show every hop with its status code, the final status and the final URL. Anything that should be permanent but shows a 302, or takes more than one hop to arrive, is worth fixing at the source.