Last updated: November 2026. Written by Syed Usman Riaz.

A 301 redirect is a server response that tells browsers and search engines a page has moved permanently to a new URL, so visitors and Google are sent there automatically. Google treats a 301 (and its twin, the 308) as a strong signal that the new URL should replace the old one in search, while a 302 or 307 says the move is temporary. Use a 301 whenever a URL changes for good, point it straight at the most relevant new page, avoid chains, and keep it in place for at least a year.

This guide covers every redirect type and how Google reads it, a decision table for common situations, copy-ready code for Apache, Nginx, WordPress, Shopify and Cloudflare, a migration redirect map template, how to test your redirects and the mistakes that quietly cost traffic.

Key takeaways

  • Permanent move: 301 or 308. Temporary: 302 or 307. Google treats permanent redirects as a strong canonical signal and temporary ones as a weak one.
  • Redirect to the closest equivalent page, not the homepage. Sending many old URLs to one unrelated page can be treated as a soft 404.
  • Go straight to the final URL. Google’s crawlers follow up to 10 hops, but Google advises redirecting to the final destination directly, and ideally no more than 3 hops.
  • Server-side redirects first. Use meta refresh or JavaScript redirects only when you can’t change the server.
  • Keep redirects for at least 1 year (Google’s own guidance), and longer if old URLs still get links or visits.

What is a redirect?

A redirect sends anyone who requests one URL to a different URL. When a browser or Googlebot asks for https://example.com/old-page/, the server answers with a status code (a three-digit number that describes the response) in the 3xx range plus a Location header that names the new address. The browser then loads the new address, usually so fast the visitor never notices.

Here is what a 301 response looks like when you inspect it:

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

Redirects matter for SEO because URLs collect value over time: rankings, backlinks from other sites, bookmarks and internal links. If you change a URL without a redirect, the old address returns a 404 (not found) error, visitors hit a dead end and search engines have to discover the new page from scratch. A redirect carries both people and search signals to the new address.

Redirects are one part of technical SEO, the work that lets search engines crawl and index your site properly. If you’re new to the subject, start with what is SEO.

What is the difference between 301, 302, 307 and 308 redirects?

The difference is permanent vs temporary, plus a technical detail about whether the browser keeps the original request method. Google sorts every redirect into one of two groups (Google Search Central: Redirects and Google Search):

CodeNamePermanent or temporaryHow Google treats itKeeps request method?
301Moved PermanentlyPermanentStrong signal that the target should be the canonical URLNot guaranteed (browsers may turn a POST into a GET)
308Permanent RedirectPermanentSame as 301Yes
302FoundTemporaryFollows it, but weak canonical signal; the old URL may stay indexedNot guaranteed
307Temporary RedirectTemporarySame as 302Yes
303See OtherTemporarySame as 302No, always becomes GET

Google’s HTTP status code documentation says plainly that 308 is equivalent to 301 and 307 is equivalent to 302 for its crawlers (Google: How HTTP status codes affect Google’s crawlers).

301 vs 302: which one should you use?

Use a 301 when you’re sure the redirect won’t be reversed: the old URL is gone for good. Use a 302 when the original URL is coming back, for example during a short maintenance window or a temporary promotion. The practical difference is which URL Google shows in search. With a 301, Google moves its focus to the new URL. With a 302, Google often keeps showing the old URL, because you told it the move is temporary.

In my client work since 2014, the redirect mistake I’ve found most often is a 302 used by accident for a permanent move. Some tools and server setups default to 302 unless you say otherwise, and the redirect still “works” in a browser, so nobody notices. Check the status code, not just where the browser lands.

When do you need 307 or 308?

For normal pages you can treat 307 and 308 as 302 and 301. They matter mostly for forms and APIs, because they guarantee the browser repeats a POST request as a POST. Some servers also send a 307 internally when HSTS (a security setting that forces HTTPS) is on; that one happens inside the browser and Google doesn’t see it.

What about meta refresh and JavaScript redirects?

Server-side redirects (301, 302 and the rest) are the method Google prefers. When you can’t change the server, two client-side options exist, and Google treats them differently (Google Search Central):

  • Instant meta refresh (a delay of 0 seconds) is treated as a permanent redirect. Delayed meta refresh (more than 0 seconds) is treated as temporary. It goes in the page’s <head>:
<meta http-equiv="refresh" content="0; url=https://example.com/new-page/">
  • JavaScript redirects are a last resort. Google only sees them after it renders the page, and rendering can fail, so Google might never see the redirect. Google’s own advice is to use them only if you can’t do server-side or meta refresh redirects.
<script>
  window.location.replace("https://example.com/new-page/");
</script>
  • Crypto redirects are simply a link on the old page saying “this page has moved to…”. Google may or may not treat them as a redirect, so don’t rely on them unless you have no other choice.

How does Google treat signals passed through a redirect?

When Google finds a permanent redirect, it treats the target URL as the likely canonical, the one version it shows in search. Links, relevance and other signals pointing at the old URL are consolidated onto the new one. Google has not published a percentage of value that a 301 keeps, so ignore any exact figure you see quoted. What Google’s guidance does make clear is that the redirect works best when the new page genuinely replaces the old one.

A few details are worth knowing:

  • The old URL can still appear for a while. Google keeps the old address as an “alternate name”, so after a move you may see old URLs in results. This fades without any action.
  • Content on the redirecting URL is ignored. Google processes the final target’s content, not anything the old URL returns along with the redirect.
  • Redirects are one canonical signal among several. Internal links, your sitemap and rel="canonical" tags should all point at the new URL too. If they still point at the old one, you’re sending mixed signals. My canonical tag guide explains how these signals work together.
  • Expect temporary movement. For a site move, Google says it can take a few weeks or more for medium-sized sites before new URLs replace old ones in results, and larger sites can take longer (Google: Site moves with URL changes).

Which redirect should you use in each situation?

Most decisions come down to one question: is the old URL ever coming back? Here’s how that plays out in the situations people ask about most.

Decision diagram for choosing a 301 or 308 permanent redirect, a 302 or 307 temporary redirect, or a 404 or 410 response when a URL changes
Two questions decide whether a URL needs a 301, a 302 or an honest 404.
SituationWhat to doCode
You changed a page’s URL or slugRedirect old URL to new URL301
You merged two or more pages into oneRedirect each old page to the merged page301
Moving from HTTP to HTTPSRedirect every HTTP URL to its HTTPS twin, site-wide301
Choosing www or non-wwwRedirect the version you don’t use to the one you do301
Moving to a new domainRedirect every old URL to its matching new URL, then use Search Console’s Change of Address tool301
Product temporarily out of stockKeep the page live (200) and show stock status; no redirectNone
Product permanently discontinued, close replacement existsRedirect to the replacement or the parent category301
Product discontinued, nothing similarLet it return 404 or 410None
A/B test sending users to a variant URLRedirect temporarily302
Short maintenance or seasonal pageRedirect temporarily, remove when done302 or 307
Page deleted with no replacementReturn 404 or 410, don’t force a redirectNone

Two of these deserve a note. For A/B tests, Google’s guidance on testing is to use a 302, not a 301, so it keeps the original URL indexed (Google: Minimize A/B testing impact in Google Search). For out-of-stock products, redirecting a page that will be back in a week throws away its rankings for nothing. My ecommerce SEO guide covers stock pages in more detail.

Should you redirect old pages to the homepage?

No, not as a blanket fix. Google’s site move guide says not to redirect many old URLs to one irrelevant destination such as the homepage, because it confuses users and may be treated as a soft 404: a page that technically works but that Google treats as “not found” (Google: Site moves with URL changes). When that happens, the old URL’s signals don’t pass to the homepage at all.

Use this order when choosing a target:

  1. The same content at a new URL. Always the first choice.
  2. A page that replaces it. A newer version of the article, or the replacement product.
  3. The closest parent page. A discontinued blue trainer goes to the trainers category, not the homepage.
  4. Nothing relevant? Let it return a 404 or 410 with a helpful error page. A 404 is not a penalty; it’s an honest answer.

Merging several old pages into one new page that covers all of them is fine. That’s consolidation, not a homepage dump.

What are redirect chains and loops?

A redirect chain is when one redirect leads to another before reaching the final page: /page-a/ → /page-b/ → /page-c/. Chains build up over the years. You change a slug, then move to HTTPS, then switch to non-www, and suddenly one old link takes four hops.

Before and after diagram showing a three-hop redirect chain from HTTP, www and an old slug collapsed into one 301 redirect to the final URL
Point every old URL straight at the final page, then update internal links.

Google’s crawlers follow up to 10 redirect hops by default (Google: HTTP status codes). That’s a hard ceiling, not a target. Google’s site move guidance says to redirect to the final destination directly and, if that isn’t possible, to keep chains short: ideally no more than 3 hops and fewer than 5. Each hop adds load time for visitors, and some browsers don’t support long chains.

A redirect loop is when URLs redirect to each other in a circle: /a/ → /b/ → /a/. The page never loads, and browsers show an error such as “too many redirects”. Loops usually come from two rules fighting each other, for example a plugin forcing a trailing slash while the server strips it.

How to fix a redirect chain

  1. Crawl the site (see the testing section below) and export every redirect with its full chain.
  2. For each chain, note the first URL and the final URL.
  3. Change the rule for the first URL so it points straight at the final URL.
  4. Update internal links so they point at the final URL and skip redirects entirely.
  5. Re-crawl to confirm every old URL now takes one hop.

How do you set up a 301 redirect?

The right method depends on where your site runs. Server-level rules are fastest; plugins and platform settings are easiest. Pick one place to manage redirects and stick to it, because rules spread across a plugin, .htaccess and a CDN are how chains and loops are born.

Apache (.htaccess)

On Apache hosting (most shared hosts, including many WordPress hosts), redirects go in the .htaccess file in your site’s root folder. Back up the file before editing it, because one typo can take the whole site down.

# Redirect one page (mod_alias)
Redirect 301 /old-page/ https://example.com/new-page/

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

# Force HTTPS and non-www in one hop (mod_rewrite)
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

Two tips. Put specific page redirects above general rules, because rules run in order. And if your file already uses RewriteRule, write new redirects as RewriteRule too, rather than mixing them with Redirect lines, so you know which rule fires first.

Nginx

Nginx doesn’t read .htaccess. Redirects go in the server configuration, and you reload Nginx after each change.

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

# Redirect a whole folder, keeping the rest of the path
location ^~ /blog/ {
    rewrite ^/blog/(.*)$ https://example.com/articles/$1 permanent;
}

# Send HTTP and www traffic to https://example.com in one hop
server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}

Run nginx -t to test the configuration before reloading. A failed config check is much better than a failed server.

WordPress

WordPress already redirects automatically when you change a published post’s slug: it remembers the old slug and sends visitors to the new one. For everything else, use one redirect tool:

  • Redirection (free plugin): a redirect manager with 404 logging, so you can spot broken URLs and fix them.
  • Rank Math: its Redirections module is included in the free version.
  • Yoast SEO Premium: includes a redirect manager that offers to create a redirect when you change a URL or delete a page.

Plugins redirect at the PHP level, which is slightly slower than server rules but fine for most sites. If you have thousands of redirects, server rules or a CDN are the better home. My WordPress SEO guide covers the rest of the setup.

Shopify

Shopify creates a redirect automatically when you change a product, collection or page URL, as long as the “create URL redirect” option stays ticked when you edit it. For manual or bulk redirects, open the URL redirects screen in your admin (in the current layout it sits with your menus under Content, and Shopify’s help centre has the latest path) where you can add redirects one by one or import a CSV (Shopify Help Center: URL redirects). Shopify redirects only fire when the old URL no longer exists in the store, so delete or rename the old product first.

Cloudflare and other CDNs

If your site sits behind Cloudflare, you can redirect at the edge, before requests even reach your server. Cloudflare offers Redirect Rules for pattern-based redirects (such as a whole folder) and Bulk Redirects for long lists of one-to-one URLs, which suits migrations. Other CDNs and hosts (Netlify, Vercel, many managed WordPress hosts) offer similar redirect files or dashboards. Edge redirects are fast, but remember they override anything on your server, so document them where your team can find them.

How do you plan redirects for a site migration?

A redirect map is a spreadsheet that lists every old URL and the exact new URL it should go to. Google calls this mapping an important step for any move that changes URLs. Build it before launch, not after rankings drop.

Six-step site migration redirect process: list old URLs, map them to new URLs, write 301 rules, test on staging, re-test after launch and monitor
Build and test the redirect map before launch, then keep redirects for at least a year.
  1. List every old URL that matters. Combine a full site crawl, your XML sitemap, the Pages report in Google Search Console and your analytics landing pages. Add URLs with backlinks from your backlink tool.
  2. Match each one to its new URL. Same content first, closest equivalent second, 404 if nothing fits.
  3. Write the rules. Use patterns where the structure is consistent (a folder rename), and one-to-one rules for the rest.
  4. Test on staging. Run the old URL list through a crawler and check that each returns one 301 to the right page.
  5. Launch, then re-test on the live site the same day, and update internal links, canonical tags and your XML sitemap to the new URLs.
  6. For a domain change, use the Change of Address tool in Search Console for the old property.

Here is a template you can copy:

Old URLNew URLCodeReasonPriorityTested
/services/web-design//web-design/301URL simplifiedHigh (backlinks)✓
/blog/2019/seo-tips//blog/seo-tips/301Dates removed from URLsMedium✓
/blog/meta-tags-1/ and /blog/meta-tags-2//blog/meta-tags/301Two posts mergedMedium✓
/shop/blue-trainer-2022//shop/trainers/301Discontinued, no replacement productLow✓
/old-promo/(none)404Expired, nothing relevantLow✓

The “Priority” column is what saves you on launch day: check the high-priority rows first, because those URLs carry backlinks and traffic.

How do you test a redirect?

Never trust a redirect just because the browser ends up on the right page. Browsers cache 301s heavily and hide the hops, so test the actual responses.

Browser developer tools

Open DevTools (F12 in Chrome or Edge), go to the Network tab, tick Preserve log and Disable cache, then load the old URL. You’ll see each hop with its status code. A clean redirect shows one 301 followed by one 200.

curl

From a terminal, curl shows the raw headers. -I asks for headers only, and -L follows each hop:

curl -I https://example.com/old-page/
curl -sIL https://example.com/old-page/ | grep -iE "^HTTP|^location"

The second command prints every status code and Location in the chain. If you see more than one 3xx line, you have a chain.

Google Search Console

Use URL Inspection on the new URL to confirm Google can index it. If you inspect the old URL, expect the status “Page with redirect”, which is normal. The Page indexing report also lists “Page with redirect” and “Redirect error”; a redirect error usually means a loop, a chain that’s too long or a redirect to an empty or broken URL. My Google Search Console guide explains these reports.

Screaming Frog or another crawler

For a whole site, crawl it with Screaming Frog SEO Spider (free up to 500 URLs) or a similar tool. Use List mode to upload your old URLs from the redirect map, enable Always Follow Redirects, and export the Redirect Chains report. That one export finds chains, loops and redirects that land on 404s. The free SEO tools guide lists other crawlers.

How long should you keep 301 redirects?

At least one year, and ideally permanently. Google’s site move documentation says to keep redirects “as long as possible, generally at least 1 year”, which gives Google time to transfer signals and recrawl the old URLs (Google: Site moves with URL changes).

After a year, Google has usually moved its signals to the new URL. But people don’t stop using old links: other websites, old emails, social posts and bookmarks keep sending visitors for years. A redirect costs almost nothing to keep, so I only remove one when it’s causing a real problem, such as a conflict with a new page that needs the old URL. Before removing any redirect, check your logs or analytics for traffic to the old URL and your backlink tool for links pointing at it.

What are the most common 301 redirect mistakes?

  • Using a 302 for a permanent move. The redirect works for people, but Google may keep the old URL in search.
  • Redirecting everything to the homepage. Treated as soft 404s, so the signals you wanted to keep are lost.
  • Leaving chains after a redesign or HTTPS move. Every old URL should reach its final page in one hop.
  • Forgetting internal links. Your menus and posts still point at old URLs, so every click adds a hop. Update them; my internal linking guide shows how.
  • Redirecting URLs blocked in robots.txt. If Googlebot can’t crawl the old URL, it never sees the redirect. Check your robots.txt.
  • Redirect rules in three places. Plugin, .htaccess and CDN rules that overlap cause loops. Pick one home.
  • Canonical tags pointing at the old URL. The redirect says “new”, the canonical says “old”. Make every signal agree.
  • Removing redirects a few months after a migration. Traffic and links from old URLs fall straight onto 404s.
  • No redirect at all when changing slugs. The most common one on small sites, and the easiest to prevent.

Frequently asked questions

Do 301 redirects hurt SEO?

Not when used correctly. A 301 to a closely matching page passes the old URL’s signals to the new one. The harm comes from mistakes: redirects to irrelevant pages, long chains, or removing redirects too soon.

Is a 301 or 302 better for SEO?

Neither is “better”; they say different things. Use a 301 when the move is permanent so Google shows the new URL, and a 302 when the old URL will come back so Google keeps it indexed.

How do I redirect a page without access to the server?

Use your CMS or platform: a WordPress plugin, Shopify’s URL redirects screen, or your CDN’s redirect rules. If none of those exist, an instant meta refresh is the next best option, and a JavaScript redirect is the last resort.

How many redirects in a chain are too many?

Google’s crawlers stop after 10 hops, but aim for one. Google’s guidance is ideally no more than 3, and fewer than 5 at most.

How long does it take Google to process a 301 redirect?

It depends on how often Google crawls the old URL. Single pages can update within days; for a full site move, Google says a few weeks or more for medium-sized sites, and longer for large ones.

Should I 301 redirect a 404 page?

Only if a relevant replacement page exists. If the content is truly gone, a 404 or 410 is the correct answer. Check the 404s that have backlinks or traffic first.

Does a 301 redirect pass PageRank?

Google says permanent redirects are a strong signal for consolidating onto the target URL, and Google representatives have said 3xx redirects don’t lose PageRank. Relevance still matters: the closer the new page matches the old one, the better the result.

Can I change a 301 redirect later?

Yes, you can edit or remove it, but browsers cache 301s, so some returning visitors may keep landing on the old target for a while. If you expect to change your mind, use a 302 until you’re sure.

Related guides

About the author

Syed Usman Riaz is an SEO specialist and the founder of Dawn of Progress. Since 2014 he has worked with an Australian web agency on local, e-commerce and WordPress SEO for client businesses, and he is Top Rated on Upwork with a 100% Job Success Score and more than 5,000 hours. He lost most of his hearing as a teenager, and he writes about using AI and SEO honestly, including where they fail.

Read my story · Start here · Work with me