301 vs 302 Redirects: Why a 301 Is Hard to Undo

PublishedTool.htaccess Generator

Contents
  1. What the two codes actually declare
  2. Search engines treat the canonical signal differently
  3. Why 301 is hard to undo: browser cache
  4. How to check and set it without a tool
  5. Where 301, 302, 307, and 308 fit
  6. Where people get stuck
  7. The short version
  8. Frequently asked questions

This post is for anyone moving an address and stuck on whether to use a 301 or a 302. The short answer: 301 declares that the address has changed permanently, and 302 declares that the content is somewhere else just for now.

This difference isn't wordplay — it behaves differently in two places. One is which address search engines treat as canonical; the other is whether browsers store the response in cache.

Summary ① 301 is a permanent move, 302 a temporary one. A client that receives a 302 keeps using the original address for future requests. ② Search engines use only permanent redirects as a signal that the new address is canonical; with temporary redirects, the original address stays in search results. ③ 301 is a status code that caches may store with their own chosen lifetime even without an expiration time, so if you get it wrong, it's hard to undo in visitors' browsers.

What the two codes actually declare

The definitions in the HTTP spec (RFC 9110) are short.

  • 301 Moved Permanently — a new permanent URI has been assigned to the target resource, and future references should use the new URI.
  • 302 Found — the target resource resides temporarily at a different URI. The spec adds one line: because the redirect may change later, the client should keep using the original address for future requests.

So a 302 means "go there this once," and a 301 means "forget that address from now on." They may look like they take you to the same screen, but the instruction they leave with the client is the opposite.

Search engines treat the canonical signal differently

Google's search documentation explains the two cases separately. A permanent redirect is used during indexing as a signal that the redirect target is canonical, and the new address appears in search results.

A temporary redirect is not used as that signal. Crawlers follow the redirect, but the original page stays in search results.

So the choice is about intent, not preference. If the address you want in search results is the new one, use 301; if it's the original, use 302.

A 302 is the right fit when you're sending visitors to a notice page during maintenance or temporarily routing them around a time-limited page.

Why 301 is hard to undo: browser cache

This is where things go wrong in practice.

The HTTP caching spec (RFC 9111) allows a cache to estimate a freshness lifetime on its own when a response has no explicit expiration time. This is called heuristic caching.

But it doesn't apply to every response. It applies only to the status codes the spec explicitly lists as eligible for heuristic caching. 301 is on that list; 302 is not.

  • 301: even without Cache-Control, a cache can choose a lifetime and store it.
  • 302: without an explicit cache directive, it is not stored heuristically.

A stored 301 doesn't go through the server

Once a visitor's browser stores a 301, the next request goes straight to the new address without asking the server. Even if you delete the rule on the server, that visitor still sees the redirect.

That request never appears in your server logs at all. That's how you end up in the "I fixed it, so why does it keep redirecting?" situation.

And you can't clear a cache stored in someone else's browser. There's little you can do besides fix things on the server and wait.

So what to do

  • Start moves that aren't final with a 302. Promote to 301 once you're sure there's no going back.
  • Even when you use a 301, set an explicit expiration time with Cache-Control in the response so caches don't estimate a lifetime on their own. How to set it depends on the web server.
  • When checking in your own browser, use a private window (incognito) or clear your browser cache. That way you make a fresh request with no stored redirect.

How to check and set it without a tool

Check which code is being sent now

Just fetch the headers in your terminal.

curl -I https://example.com/old-page

The first line shows HTTP/1.1 301 Moved Permanently or HTTP/1.1 302 Found, and Location: below shows the destination address.

To see whether the redirect chains through several steps, use -IL. It follows them and shows the status code at each step in order.

curl doesn't go through the browser cache. So it shows exactly what the server is sending right now. If curl returns 302 but the browser keeps redirecting, the cause is the cache, not the server.

You can also check the Status column in the Network tab of your browser's developer tools (usually F12). Turn on Disable cache so you see the server response.

Choosing the code in Apache

There are two ways to set redirects with .htaccess. The important part: both default to 302.

The first is Redirect from mod_alias. You put the status first, and you can use a name instead of a number.

Redirect 301 /old-page https://example.com/new-page
Redirect permanent /old-page https://example.com/new-page
Redirect temp /old-page https://example.com/new-page

permanent is 301, temp is 302, and seeother is 303. Per Apache's docs, if you omit the status, you get 302. This is where people often ship a temporary redirect for a permanent move by mistake.

The second is the R flag in mod_rewrite.

RewriteRule ^old-page$ https://example.com/new-page [R=301,L]

If you use just R and omit the code, it also defaults to 302. If you want 301, you have to write R=301.

The problem is that once you start adding HTTPS enforcement and www unification rules, the condition order and flags get long fast.

Check it with our .htaccess Generator. Pick the basic rules with checkboxes, choose how to handle www, then enter the old path and new address, and the finished .htaccess body appears right away.

.htaccess Generator

No install and no sign-up: the rules are assembled right inside your browser, and the paths you enter are never sent to a server.

This generator creates only 301 redirects. If you need a temporary one, change Redirect 301 to Redirect 302 and [L,R=301] to [L,R=302] in the output.

Where 301, 302, 307, and 308 fit

301 and 302 have one more catch. RFC 9110 notes that for both codes, user agents may change a POST request to GET for historical reasons.

If you must preserve the method, use 307 (temporary) and 308 (permanent). 307 is the code where the spec requires the method to stay the same, and 308 is its permanent version.

CodeMeaningRequest methodStored without an expiration time
301Permanent movePOST may become GETYes
302Temporary movePOST may become GETNo
307Temporary moveMust be preservedNo
308Permanent moveMust be preservedYes

Normal page moves are GET requests, so 301 and 302 are enough. Only when you move an address that receives form submissions (POST) do you need to consider 307 and 308.

Where people get stuck

SituationWhat happens
A→B→C chainsEvery hop adds another round trip, and leftover middle rules make cleanup hard
Rules that bounce back to each otherIf the force-www rule and the force-HTTPS rule point at each other, you get a loop
Adding a 301 first, then canceling itYou can fix the server, but the cached copy stays
Leaving out the status codeBoth Apache methods send a 302

For redirect loops, the spec says the client has to detect it and step in. A note from an older version recommending a maximum of five also survives in the text, so a long chain can break partway through.

When you add a new rule, it's safer to send visitors straight to the final address rather than to an intermediate one. A single typo in .htaccess can throw a 500 error across the whole site, so keep a backup before you go live.

The short version

  • 301 is permanent, 302 is temporary. A client that gets a 302 keeps using the original address going forward.
  • Search engines use only permanent redirects as a signal to treat the new address as canonical. With a temporary redirect, the original address stays in the results.
  • 301 is a status code that caches are allowed to store even without an expiration time. Once it's stored, requests skip the server, so undoing it is hard.
  • Start an unconfirmed move with a 302, and upgrade to 301 once there's no chance you'll revert.
  • Check what you're actually sending with curl -I. curl doesn't go through the browser cache.
  • Apache's Redirect and RewriteRule [R] both default to 302 when you leave the code out. You have to state 301 explicitly.
  • If you need to preserve the POST method, use 307 or 308.
.htaccess Generator

No install and no sign-up: the rules are assembled right inside your browser, and the paths you enter are never sent to a server.

Frequently asked questions

I changed a 301 to a 302, but my browser still goes to the old page

First, check the server response with curl -I. If curl shows a 302, the server is already fixed and what's left is the 301 cached in your browser. Open the site in a private window or clear your browser cache and it clears up on your screen. You can't clear other visitors' caches, though — you have to wait for them to expire.

Should I always use a 301 for SEO?

If your goal is to get the new address into search results, 301 is the right call. But if you put a 301 on a move you might reverse, canceling it won't take effect right away because of the cache stored in visitors' browsers. Google's documentation also says to use a permanent redirect only when you're sure you won't need to undo it.

I set up a redirect, but the address in search results hasn't changed

Indexing takes time because Google has to crawl the page again. Google doesn't give a number for how long that takes. Don't guess — use the URL Inspection tool in Search Console, enter the address, and check the status Google sees and the canonical address it picked.

Does the path I type into the generator get sent to a server?

No. The generator assembles the checkbox selections and the paths you enter inside your browser to build the output text. Your input isn't sent to a server or stored, and the download button just saves the file your browser created.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. Resume photo URL not showing: how to check a direct image linkPasted a photo URL into Resume Builder but it won't show in the preview or PDF? Learn why page links fail and how to find the direct image link.
  2. robots.txt Disallow vs noindex: Why Blocked Pages Still ShowDisallow only blocks crawling, not indexing. So blocked URLs can still show up in search results without a snippet. Here's how noindex differs.
  3. Transparent PNG Signature: Draw on Canvas and SaveDraw your signature on a canvas and save it as a transparent PNG. How alpha channels work, and how image signatures differ from certified ones.
  4. Sitemap priority and changefreq are ignored: what lastmod meansGoogle's docs say it ignores sitemap priority and changefreq. See what the spec sets, when lastmod actually counts, and why a sitemap doesn't guarantee indexing.
  5. How to Split People Into Teams: Team Sizes and RemaindersSee how many people land in each team when the headcount doesn't divide evenly, and how the extra people are added to the first teams.
  6. Why You Shouldn't Use Real Customer Data as Test DataCopying production data spreads real customer info through dumps, logs, and reports. Learn to spot it and generate fake data instead.

Related tools