</> ConvertAtlas Developer Tools
Web

301 vs 302 Redirects: Which to Use and Why It Matters

The SEO and caching differences between permanent and temporary redirects, and how to write the rules for Apache and Nginx.

/old-url 301 /new-url

Redirects keep the web from breaking when URLs change, but choosing the wrong type can quietly cost you search rankings or cause confusing caching behaviour. The distinction between a 301 and a 302 is small in code and large in consequence.

/old-url 301 /new-url
A 301 sends both browsers and search engines permanently to the new URL.

301: permanent

A 301 tells browsers and search engines that a resource has moved for good. Search engines transfer the old URL’s ranking signals to the new one and update their index. Browsers cache the redirect aggressively. Use 301 when you have genuinely moved a page, restructured a site, or consolidated duplicate URLs.

302: temporary

A 302 says the move is temporary — keep using the original URL because the redirect will go away. Search engines generally keep the original URL indexed and do not transfer ranking. Use 302 for short-lived situations: A/B tests, maintenance pages, or geo/device redirects you intend to reverse.

The SEO consequence of getting it wrong

Using a 302 for a permanent move is the classic mistake. The new URL may never accumulate the ranking the old one had, because search engines are waiting for you to "come back". Conversely, a 301 you cannot easily undo (because browsers cache it hard) is the wrong choice for something genuinely temporary.

Try it: Redirect Rule GeneratorGenerate 301/302 redirect rules for Apache .htaccess and Nginx.

Writing the rules

On Apache, redirects live in .htaccess using Redirect or RewriteRule with an R=301 or R=302 flag. On Nginx, they go in a server block using return 301 or return 302. The syntax differs enough to be worth generating rather than hand-typing, especially when you are switching between servers.