Every redirect rule answers two questions: where does this URL go now, and is that move forever? The first is the easy half. The second, the status code, is where redirect plans quietly go wrong: a permanent code on a temporary detour, or a temporary code on a move that was final months ago.
The choice is smaller than it looks, and the free Redirect Rule Generator on Ovatly is built around it: each from/to row carries its own code. This guide explains what each code promises, then works through the cases you will actually meet.
Contents
- Quick answer
- The four codes in one view
- What a permanent code really commits you to
- What a temporary code protects
- 307 and 308: the method-preserving pair
- Decision cases
- How to set the code, step by step
- Worked example: reading "permanent" in the output
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Choose per rule. Use 301 when the move is final and the new URL should take over for good. Use 302 when the original URL is coming back, so it keeps its claim. 308 and 307 add the same promises with the request method preserved exactly. In the Redirect Rule Generator, the code is a per-row choice alongside each from/to pair, so one generated file can hold a mixture. The tool records your choice and validates the shape of the rules; it cannot know your plans, so the judgement is yours.
The four codes in one view
A 301 is a permanent redirect: this content lives at the new URL now. A 302 is a temporary redirect: the content is over there for the moment, but the original URL remains the real address.
A 308 is a permanent redirect with a stricter contract: the request method must not change. A 307 is the same contract in temporary form. For ordinary page moves, 301 and 302 cover nearly everything; the stricter pair matters where a form submission or API call must arrive with its method intact.
What a permanent code really commits you to
Permanent is a strong word, and browsers take it literally. A browser that receives a 301 may cache it and go straight to the new URL next time, and search engines transfer their indexing attention to the destination. Both behaviours are exactly what you want for a truly final move, like a page merged into a better one.
Both are a problem when the move was not final. Removing a 301 from your server does not remove it from a visitor's browser. So the honest test for 301 is not "is the page moving?" but "would I be content if this were very hard to reverse?" If yes, 301. If there is real doubt, it is not permanent yet.
What a temporary code protects
A 302 keeps the original URL as the address of record. Browsers do not treat it as a lasting instruction, and search engines keep their attention on the original URL. That is the right shape for a page that is away and coming back: a product out of stock and pointing at its nearest alternative this week, a page pulled during a short redesign, a seasonal swap.
The failure mode is the opposite one: a 302 left in place after the move became final. The old URL keeps its claim, the new one never fully takes over, and the site sends a temporary signal about a permanent fact for months. Temporary codes deserve a calendar entry: when the detour ends, remove the rule or change the row to a 301.
307 and 308: the method-preserving pair
With 301 and 302, a client is historically allowed to change the method of the follow-up request, turning a submission into a simple fetch. For page moves nobody notices; for data submissions, that change can break the request.
307 and 308 remove the ambiguity: the method is preserved, guaranteed. Pick 307 for a temporary move and 308 for a permanent one when form posts or API calls must keep their method. They are two more choices in the same per-row setting, and in Nginx output they are emitted as exact-match location blocks with a return line rather than plain rewrite lines.
Decision cases
Permanent move. The old URL will never serve again. Code 301, or 308 if method preservation matters.
Temporary detour. The original URL returns soon. Code 302, or 307 under the same method condition.
A/B or maintenance detour. Traffic is sent elsewhere while you test or repair, and the original setup is expected back unchanged. A temporary promise even if it lasts weeks: 302 or 307.
Mixed plan. A redesign where most pages move for good but two are only detouring. The normal case, and why the code sits on each row: 301 for the final moves, 302 for the detours, one file.
How to set the code, step by step
- Open the Redirect Rule Generator and enter a from/to row for each URL you are moving.
- For each row, ask: is the original URL coming back? Set 301 (or 308) if not, 302 (or 307) if it is.
- The generator refuses a duplicate from-path, so one URL can never carry two conflicting promises.
- Pick your output format,
.htaccess, Nginx or_redirects, and copy the rules into place. - Deploy, then test: visit the old URLs and confirm each redirect fires as intended.
Worked example: reading "permanent" in the output
One row, from /old-soap to /soap, with the permanent choice made, produces this Nginx line:
rewrite ^/old-soap$ /soap permanent;
The word permanent in that line is the 301 promise, spelled out. Read your output this way before deploying. If a line says permanent about a page you expect back next month, the row's code is wrong, and fixing it now is a one-click change; fixing it after browsers have cached the permanent version is a waiting game. The anchors pin the match to exactly /old-soap, and regex characters in a from path are escaped automatically, so the code applies to the one URL you meant.
Limitations and honest tradeoffs
The generator records the code you choose and validates the shape of the rules only. It cannot tell you whether a move is permanent, because that is a fact about your plans, not the URL. Nor can it confirm your server applied the rules or that the destination responds as expected; test after deploying, every time.
There is also a limit to what any code can promise. A 301 asks search engines to transfer attention to the new URL, and in practice they do, but neither tool nor code can guarantee how a particular engine or browser will treat your site. Choose the code that tells the truth about your intentions.
Common mistakes
- Using 302 for a permanent move. The old URL keeps its claim and the new one never takes over.
- Using 301 for a temporary detour. Browsers cache it, and the detour outlives your rule change.
- Setting one code for the whole file. Real plans are mixed; each rule should tell its own truth.
- Skipping the test. A shape-valid rule can still be ignored by a server that never loaded the file.
FAQs
What is the difference between a 301 and a 302 redirect? A 301 says the move is permanent: browsers and search engines should transfer their attention to the new URL, and browsers may cache the decision. A 302 says the move is temporary: the original URL is expected back, so the signal keeps pointing at it.
Can different rules in one file use different status codes? Yes. Every from/to row has its own code, so one file can mix 301s for final moves with a 302 for a temporary detour.
What are 307 and 308 redirects? They are the stricter, method-preserving versions of 302 and 301: 307 temporary, 308 permanent, in the same per-row choice as 301 and 302.
What happens if I use a 301 for a move that turns out to be temporary? Browsers cache permanent redirects aggressively, so visitors may keep being sent to the new URL even after you remove the rule, until their cache clears. Treat 301 as hard to take back, and use 302 whenever the original URL might return.
Does the generator choose the right code for me? No. It records the code you pick for each row and validates the shape of the resulting rules. Whether a move is permanent or temporary is a fact about your plans, so the judgement stays with you.
Conclusion
The status code is a promise about the future, made one rule at a time: 301 when the old URL is done, 302 while it is only away, 307 or 308 when the method has to survive the trip. The Redirect Rule Generator keeps that promise attached to each row, so a mixed plan produces a mixed, honest file. When the job is a whole folder moving at once, our guide to redirecting a whole folder of pages covers the two routes that work, including the one line you write by hand. For more guides in this series, see our Website and Webmaster Tools guides.
References
- MDN Web Docs, on HTTP response status codes, including the redirect family: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status
- MDN Web Docs, on HTTP redirections and when each status code applies: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Redirections