301 and 302 redirects: the difference and how to set them up without losing SEO

8 minutes

A redirect sends a visitor from one address to another: the server responds with a code in the 3xx range and gives the new address in the Location header, and the browser or search engine crawler follows it. Which code you use — 301 or 302 — determines how the search engine treats the old and new addresses.

Below — how the main redirect codes differ, how to set up a redirect on the server, why chains and loops are risky, and the most common mistakes.

What a redirect is and when you need one

How a redirect works

A browser or crawler requests a page. The server responds with a code in the 300–399 range and a Location header that holds the new address. The client follows that address — for the user, this is usually invisible and happens instantly.

GET /old-page/ HTTP/1.1
Host: example.com

HTTP/1.1 301 Moved Permanently
Location: https://example.com/new-page/

When you need a redirect

Typical reasons to set up a redirect:

  • the page’s address has changed (a new URL, a new section structure);
  • several pages have been merged into one, and the old addresses should lead to the merged version;
  • a page is temporarily unavailable and needs to be replaced by another one for a while.

301 and 302: what’s the difference

301 Moved Permanently

A 301 code means the target resource has been assigned a new permanent address. Google treats this as a signal that the page has moved for good: it follows the new address and starts treating it as the page’s canonical version. Given a correct response, Yandex indexes the target page if it’s accessible.

302 Found

A 302 code means the resource is temporarily located at a different address. For Google, this signals not to move the page permanently: a 302 doesn’t automatically make the target address the canonical version, and the target page can only become canonical given other normalization signals. Yandex doesn’t distinguish between 301 and 302 handling here: its crawler indexes the target page if it’s accessible, regardless of which of these two codes the redirect uses — the difference in canonicity is specific to Google. Use a 302 when you know for certain the redirect is temporary — for example, during maintenance work.

303, 307, 308 — why the other codes exist

All redirect codes belong to the same class of server responses — 3xx (Redirection). Besides 301 and 302, HTTP has three more redirect codes, which differ in what happens to the request method:

  • 303 See Other — the client must follow the new address using the GET method, even if the original request was a POST. It’s used so that reloading the page after a form submission doesn’t resubmit it.
  • 307 Temporary Redirect — a temporary redirect, but unlike 302 the request method is preserved: a POST stays a POST.
  • 308 Permanent Redirect — a permanent counterpart to 301 that likewise preserves the request’s method and body.
CodeNamePermanenceRequest method changesWhen to use
301Moved Permanentlypermanentmay change to GETchanging a page’s address, merging pages
302Foundtemporarymay change to GETtemporary unavailability, a short-term A/B test
303See Othertemporarychanges to GETnavigation after a form submission (POST)
307Temporary Redirecttemporarydoesn’t changetemporary unavailability when preserving the method matters (for example, an API)
308Permanent Redirectpermanentdoesn’t changea permanent move that preserves the method and body

How to set up a redirect

nginx

nginx has the return and rewrite directives for redirects. return immediately returns the code and address without processing the request any further:

location /old-page/ {
    return 301 https://example.com/new-page/;
}

rewrite with the permanent or redirect flag changes the URI by a regular expression and returns a 301 or 302 respectively:

rewrite ^/old-page/$ /new-page/ permanent;

Apache (.htaccess)

In Apache, the Redirect directive (the mod_alias module) handles redirects. The permanent argument returns code 301, and temp (the default) returns 302:

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

For redirecting by an address pattern, use RedirectMatch with a regular expression:

RedirectMatch 301 "^/old/(.*)$" "/new/$1"

CMS

In most content management systems, a redirect is set up through the admin panel or through the server’s configuration file. Either way, after setting it up, check the server’s actual response — the headers and the code — rather than what the admin interface shows.

Redirect chains and loops

A chain is several redirects in a row: address A leads to B, B leads to C, and so on. The longer the chain, the longer it takes the client to reach the final page. When moving a site with URL changes, Google recommends not overloading chains — keeping to a few hops rather than building a long sequence of redirects.

A loop is a special case where the chain returns to an address it has already visited (A → B → A). The browser detects this and shows an error, reporting that the server is redirecting the request in a loop. If the server itself detects the loop, it may respond with a 500 Internal Server Error code.

How a redirect affects SEO

The difference between 301 and 302 matters precisely because it affects what the search engine does with the index differently:

  • 301 — Google follows the new address and treats this as a reason to consider the target page canonical. Yandex indexes the target page if it’s accessible.
  • 302 — for Google, this doesn’t pass that signal automatically: the target page becomes canonical only given additional normalization signals, not simply because of the redirect itself. For Yandex, indexing the target page works the same way for 301 and 302 — “the crawler will index the page the redirect points to, if it’s accessible” in both cases; the difference in canonicity between 301 and 302 is specific to Google, not a general rule for both systems.

If you’re changing the site’s domain entirely, keep the redirects in place for a long time: Google advises not disabling the redirect for at least a year, so the signals have time to transfer to the new address.

A redirect isn’t the only tool for duplicates. If several addresses need to stay accessible but one of them should be marked as the primary version, canonical is used instead of moving the page — we covered how to choose between a redirect and canonical separately.

A historical example of how a redirect decision changes a site’s infrastructure: the Host directive in robots.txt used to tell Yandex the site’s primary mirror, but it was replaced by a page-by-page 301 redirect — more on how the robots.txt file is structured in a separate article.

Common mistakes when setting up redirects

MistakeConsequenceHow to fix it
A 302 instead of a 301 for a permanent moveThe target page doesn’t become canonical automaticallyUse a 301 (or 308) if you’re sure the move is final
A long redirect chainSlower loading, higher risk the hop won’t reach the targetPoint the redirect straight at the final address, without intermediate steps
A redirect to an irrelevant page (for example, to the homepage instead of a similar one)The user and the crawler don’t get the content they expectedLook for the most similar live page for each address
No redirect when merging pagesThe old address returns a 404, and internal and external links to it stop making senseSet up a 301 from the old address to the merged page
A redirect loop (an address refers back to itself through a chain)The browser shows a loop error, and the server may respond with a 500Check the final chain after every configuration change

If a page doesn’t make it into the index after a redirect, or behaves differently than expected, the cause may not be the redirect itself — more on how pages enter and drop out of the index in the article on indexing.

Frequently asked questions

Do you need to delete the old page after setting up a redirect?

There’s no technical requirement to delete the content — it’s enough for the page to respond with a code in the 3xx range instead of a 200.

How many redirects in a row are acceptable?

Sources don’t give an exact number; Google recommends not building long chains when moving a site. In practice, the shorter the chain, the more reliable the hop.

Does a page’s “weight” carry over through a 302?

For Google, a 302 doesn’t make the target page canonical automatically: that only happens given additional normalization signals, not simply because of the temporary redirect. For Yandex, the question looks different: indexing the target page works the same way for 301 and 302 if the page is accessible — the difference in canonicity is specific to Google.

Can you redirect a deleted page to the homepage?

Technically yes, but for the user and the crawler it’s less relevant than a hop to a similar live page. Picking the right redirect target is a separate task for each address.

Do you need a redirect when switching the protocol from http to https?

Yes, the mechanics are the same: the server must respond with a 3xx code and the new address in Location.

Sources

Documentation the article relies on (checked October 21, 2026):

Redirects set up at some point often go unwatched after later releases. We’ll check the redirect rules and server responses as part of technical SEO. → Discuss technical SEO