301 vs 302 redirects: which to use
When a page moves, a redirect sends visitors and search engines to the new address. The status code tells them whether the move is permanent. This guide explains the codes and the mistakes the 301 Redirect Generator checks for.
Free tools for this
1. The codes
| Code | Meaning | Use it when |
|---|---|---|
| 301 | Moved permanently | A page has a new address for good |
| 308 | Moved permanently, same request method | Like 301, mainly for forms and APIs |
| 302 | Found (temporary) | The old address will come back, such as during maintenance |
| 307 | Temporary, same request method | Like 302, for forms and APIs |
Google's documentation says it treats 301 and 308 as a strong signal that the new address should be the one shown in search, and 302 and 307 as a weak one. For a page that has really moved, use 301.
2. Mistakes that break redirects
- Query strings. Apache's Redirect and Nginx's rewrite match only the path, not the part after ?. A rule for /page?id=5 written the simple way never fires. It needs a RewriteCond on the query string (Apache) or a check of $request_uri (Nginx).
- Loops. A rule that sends a page to itself, or two rules that send pages to each other, leaves the browser with an error.
- Chains. /a โ /b โ /c works, but each hop slows the visitor and wastes crawling. Point /a straight to /c.
- Prefix matches. In Apache, Redirect 301 /blog also moves /blog/post-1 to /news/post-1. Put deeper paths first if they go elsewhere.
- Sending everything to the home page. Redirect each old page to its closest replacement; a home-page redirect for unrelated pages is treated like a missing page.
3. Where the rules go
- Apache: the .htaccess file in the folder where the site starts (often public_html).
- Nginx: inside the server block, then reload Nginx.
- Cloudflare Pages and Netlify: a file named _redirects in the site's root, with lines like /old /new 301.
4. Test before you move on
- Open each old address and confirm it lands on the right page.
- Check the status code with your browser's developer tools (Network tab) or a command such as curl -I.
- Update internal links and your XML sitemap to the new addresses, so the redirect is only a safety net.
Source: Google Search Central, Redirects and Google Search (developers.google.com/search/docs/crawling-indexing/301-redirects).
Questions
Does a 301 redirect lose SEO value?
Google uses a 301 as a strong signal to show the new address instead of the old one; keep the redirect in place and update your own links.
How long should I keep a 301 redirect?
As long as people or other sites might still use the old address; for most sites that means keeping it permanently.
Can I redirect a URL with a query string?
Yes, but not with a plain Redirect line. Use the generator, which writes the matching RewriteCond or $request_uri rule.