webtrajans
en

301 vs 302 redirects: which one should you use?

Use a 301 (or 308) when a URL has moved for good and a 302 (or 307) when the move is temporary. The details below cover SEO, chains, loops and server configuration.

Updated: 5 min read

A redirect tells browsers and search engines that the content at one URL now lives somewhere else. Get it right and visitors, backlinks and rankings move smoothly to the new address. Get it wrong (a temporary code for a permanent move, a chain of five hops, a loop) and you lose traffic, slow the site down or make pages disappear from search results.

The four redirect codes

Code Name Permanent? Keeps method (POST stays POST)? Typical use
301 Moved Permanently Yes Not guaranteed Page or site moved for good
302 Found No Not guaranteed Short-term moves, A/B tests, geo or login redirects
307 Temporary Redirect No Yes Temporary redirect of forms or API calls
308 Permanent Redirect Yes Yes Permanent move where method must be preserved

For ordinary web pages, 301 and 308 behave the same for SEO, as do 302 and 307. The method distinction mainly matters for APIs and form submissions.

There are also meta refresh and JavaScript redirects. Google can follow them, but they’re slower and less reliable signals. Use server-side redirects wherever possible.

How redirects affect SEO

  • Permanent (301/308): Google treats it as a strong signal that the target should be the canonical URL. Over time the old URL drops out of the index and the new one inherits its signals.
  • Temporary (302/307): Google tends to keep the original URL indexed, because you’ve said it will come back. If a “temporary” redirect stays for months, Google may eventually treat it as permanent, but don’t rely on that.

Rules of thumb:

  • Redirect each old URL to the most relevant new URL. Mass-redirecting everything to the homepage is often treated as a soft 404.
  • Update internal links, canonical tags and the XML sitemap to point directly to the new URLs.
  • Keep redirects for at least a year; for valuable backlinks, indefinitely.

Redirect chains and loops

A chain happens when A redirects to B, which redirects to C. They build up over years: HTTP → HTTPS → www → new slug → trailing slash. Each hop adds latency (a full round trip, more on mobile) and increases the chance that something breaks.

A loop is when A eventually redirects back to A. Browsers show ERR_TOO_MANY_REDIRECTS. Common causes:

  • HTTPS forced at both the CDN and the server with conflicting settings (e.g. Cloudflare “Flexible” SSL with a server-side HTTPS redirect).
  • www forced in one place and non-www in another.
  • A WordPress site URL that doesn’t match the server redirect rules.

Paste any URL into our redirect checker to see every hop, its status code and the final destination. The goal is one hop from any old variant to the final URL.

.htaccess examples (Apache)

Generate rules for many URLs at once with our 301 redirect generator, or write them by hand:

## Single page
Redirect 301 /old-page/ https://example.com/new-page/

## Whole folder, keeping the rest of the path
RedirectMatch 301 ^/blog/(.*)$ https://example.com/articles/$1

## Old domain to new domain, keeping paths
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]

## Force HTTPS and non-www in one hop
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]

Order matters: put specific page rules before broad catch-all rules, or the catch-all will fire first.

nginx examples

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

## Whole folder
location ^~ /blog/ {
    rewrite ^/blog/(.*)$ /articles/$1 permanent;
}

## Old domain to new domain
server {
    server_name old-domain.com www.old-domain.com;
    return 301 https://new-domain.com$request_uri;
}

In nginx, permanent produces a 301 and redirect a 302. For many individual URLs, a map block is cleaner and faster than hundreds of location blocks.

Redirects in WordPress, Shopify and CDNs

If you don’t manage the server directly:

  • WordPress: a redirect plugin (Redirection, Rank Math, Yoast Premium) stores rules in the database and logs 404s so you can spot missing redirects. Server-level rules are faster, but plugins are fine for a few hundred URLs.
  • Shopify: Online Store → Navigation → URL Redirects, with CSV import for bulk changes. Shopify can create a 301 automatically when you change a product’s URL handle.
  • Cloudflare and other CDNs: redirect rules and bulk redirect lists run at the edge before requests reach your server, which is ideal for domain moves.
  • Static hosts (Netlify, Cloudflare Pages) use a _redirects file with lines like /old-page /new-page 301; others use a config file.

Keep all redirects in one place where possible. Rules spread across a plugin, .htaccess and a CDN are how chains and loops are born.

Verifying redirects

After deploying, check the actual response headers with the HTTP header checker:

HTTP/2 301
location: https://example.com/new-page/

Watch out for:

  • a 200 where you expected a redirect (the rule didn’t match),
  • a 302 where you wanted a 301 (common default in plugins and some frameworks),
  • redirects that drop the query string or the path.

Site migration checklist

  1. Crawl the old site and export every URL, including images and PDFs that have backlinks.
  2. Map each old URL to its new equivalent in a spreadsheet.
  3. Implement 301s in one hop, specific rules first.
  4. Test a sample of URLs and all host variants (http, https, www, non-www).
  5. Update internal links, canonicals, hreflang tags and sitemaps.
  6. Submit the new sitemap and, for a domain change, use Search Console’s Change of Address tool.
  7. Monitor 404s and Search Console coverage reports for several weeks.

For the HTTPS side of migrations, see what an SSL certificate is and how to fix SSL errors.

Frequently asked questions

Do 301 redirects lose SEO value?

Google has said that 3xx redirects don't cause a loss of PageRank. Rankings can still shift if the new page is less relevant, so redirect each old URL to its closest equivalent rather than to the homepage.

How long should I keep a 301 redirect?

As long as possible, and at least a year. Google recommends keeping redirects in place for at least a year; old backlinks and bookmarks may keep using the old URL for far longer.

What is the difference between 302 and 307?

Both are temporary. A 307 guarantees the browser repeats the same HTTP method and body, so a POST stays a POST; with 302, browsers historically switched POST to GET.

How many redirects in a chain are too many?

Aim for a single hop. Googlebot follows up to 10 hops, but every extra hop slows users down and risks errors, so update old redirects to point straight to the final URL.

Related guides