A redirect map pairs each old URL with the one new address that should answer for it, and a migrated site keeps its pages in search when every pair is a direct, permanent redirect ending on a page that is really there. Build it from the old addresses that people and crawlers actually use, decide each target by hand, send every request to its final address in one hop, and then prove the result by requesting each old URL and reading what comes back. The steps below end with a script that is able to fail, which is what makes it worth running. They apply to any site migration where the content survives and only the addresses change.

Start from the old URLs that matter

You cannot map what you have not listed. Google's move guide suggests three starting points: the sitemap, because the important pages are usually in it, the server logs or analytics for the addresses that get visits, and the content system's own list of pages. It also says to include the addresses of images, videos, scripts and stylesheets, since they move like any other file (Google, how to move a site).

Add one more source: pages that other sites link to. Search Console shows links to your site, and the same guide asks you to save that list for after the move, so you can ask those sites to update their links. Merge all the lists into one column, keep each address exactly as it was written (case, trailing slash and query string included, because each is a different URL), and remove duplicates only when they are identical character for character.

Decide each target by hand

This is the step that cannot be automated away. For every old URL, there are three possible answers:

  1. A new page carries the same content: that page is the target.
  2. Several old pages were merged into one: all of them point at the merged page.
  3. The content is gone: no redirect. Let the new site answer with a not-found or gone status.

The third case matters because the temptation is to send every leftover address to the home page. Google cautions against pointing a crowd of retired addresses at a single unrelated destination, the front page in particular: visitors get lost, and the outcome can be classed as a soft error (Google, how to move a site). The same page says that merged content may redirect to its consolidated page, so the exception is real, but it applies only when the merge actually happened.

Never fill a row because two names look alike. If you guess a target and ship it as permanent, search engines are told to trust the guess. Keep a separate list titled "no target yet" and let a person resolve it.

Variants of the same page come first. If an address answers over http and https, with and without www, choose the preferred one before you write the rows; Google's redirect page describes the same idea of picking one preferred destination and redirecting the others to it (Google, redirects).

Pick the status code

Use a permanent, server-side redirect. Google names 301 and 308 as the recommended codes for a move, and says permanent redirects show the new address in results, while temporary ones keep showing the source page (Google, redirects). The protocol document explains the difference between the two permanent codes: both mean the resource has a new permanent address, but after a 301 a client may change a POST into a GET on the next request, and 308 exists for the case where that must not happen (RFC 9110). For ordinary pages, either works. For an API endpoint that receives POST bodies, choose 308.

Temporary codes, 302 and 307 among them, signal that the move may be undone (RFC 9110), so they are the wrong choice for a migration you do not plan to reverse. A frequent source of surprise is the framework: one turns a "permanent" option into 308, another into 301, so write down what the platform really sends and test for that, not for what the option is called.

A meta refresh or a script redirect is a last resort. Google says an instant meta refresh is read as permanent, and that script redirects may never be seen if rendering fails (Google, redirects).

Collapse chains before they ship

A chain forms when the target of one redirect is itself an address that redirects onward. Google can follow up to 10 hops, but advises sending the request to the final destination directly, and if that is impossible, keeping chains short, ideally no more than 3 (Google, how to move a site). In a migration, chains grow naturally: an earlier redesign redirected to a path that a later redesign then moved again. When you add a row, look up its target in the old-URL column; if the target is there, replace it with that row's target and repeat until you land on a live page. If a walk returns to an address it already visited, you have a loop. Write no rule for those rows and resolve them by hand.

We also tested how models cope with chains and loops, in a report on orphan pages and redirect chains; the point that carries over is that the rule is easy to state and easy to break one row at a time, which is why the final check below does not trust the table.

Check the cache before you trust the redirect

One trap depends on your host, not on the table. If an old path was requested before and answered not-found, a cache may hold that answer, and adding a redirect later does not always replace it. We have seen this on a site that answered a permanent redirect with no target address, which Search Console then listed as a redirect error. We describe the case, the purge and the check in our Next.js caching guide, where we also say it is our own unmeasured observation. Treat it as a reason to purge the old paths in the same release and to run the test in the last section after deploy, not before.

Update the new site around the map

The table alone is not the migration. The Google guide lists work on the new side too: each new page gets a self-referencing canonical tag, language annotations point to the new addresses, internal links use the new URLs instead of leaning on the redirect, and a sitemap of the new URLs is ready to submit. Redirects should stay as long as possible, generally at least 1 year (Google, how to move a site).

The same guide recommends moving small and medium sites all at once, and larger ones in sections if that makes problems easier to see. Expect rankings to wobble while old and new addresses are recrawled.

A redirect map check that can fail

Reading the map proves little, and reading the server config proves little too; the live site is the only witness. The script below takes a two-column CSV (old URL, expected new URL), requests each old address without following redirects, and fails a row when the status is not a permanent one (Google names 301 and 308), when the Location header is missing or differs from the expected target, or when the target itself does not answer with a plain success. Because the target is also requested without following, a second hop shows up as a failure and not as a quiet success.

// check-map.mjs  usage: node check-map.mjs map.csv
import { readFileSync } from "node:fs";

const rows = readFileSync(process.argv[2], "utf8").trim().split("\n")
  .map((l) => l.split(",").map((s) => s.trim()));
let bad = 0;

for (const [from, to] of rows) {
  const first = await fetch(from, { redirect: "manual" });
  const loc = first.headers.get("location");
  const target = loc ? new URL(loc, from).href : null;
  const problems = [];
  if (![301, 308].includes(first.status)) problems.push(`status ${first.status}`);
  if (!target) problems.push("no Location header");
  else if (target !== new URL(to, from).href) problems.push(`goes to ${target}`);
  if (target) {
    const last = await fetch(target, { redirect: "manual" });
    if (last.status !== 200) problems.push(`target answers ${last.status}`);
  }
  if (problems.length) { bad++; console.log("FAIL", from, problems.join("; ")); }
}
console.log(bad ? `${bad} of ${rows.length} rows failed` : "all rows pass");
process.exitCode = bad ? 1 : 0;

Next, prove that the script is capable of failing, the step most people leave out. Put deliberately wrong rows in a test CSV: a retired address that is redirected only temporarily, one that lands on a different page than the table promises, one whose target is missing, and one that needs two hops. A pass for any of them means the script is looking at the wrong thing. Until you have watched it fail, its passes on the real map carry no weight.

Run it from outside your network against the production hostname, and run it again after the cache purge. Then watch Search Console: Google's guide says the old-URL sitemap will show warnings about redirecting pages, and that those warnings are expected during a move. For a changed domain or subdomain it also asks for a Change of Address request per verified variant of the old site (Google, how to move a site).

Our skills for this topic

  • The map itself: redirect-map turns your list of old URLs and chosen targets into rules, collapses chains, reports loops and unmapped addresses instead of guessing, and can write a _redirects file.
  • Choosing the canonical address: canonical-url-decision says, per URL variant, whether it is the canonical one, needs a redirect, a canonical tag, noindex or a removal status.
  • Finding stranded pages: internal-link-orphan-audit reads a crawl export and reports pages that nothing links to, links that still point at a redirect, and noindex pages sitting in the sitemap.
  • soft-404-fix finds which layer makes a missing page report success, which matters for the old URLs you decided to leave unredirected.
  • sitemap-builder writes the sitemap of new canonical addresses that you submit after the move.
  • search-console-actions names the right next click for a Search Console row, including that an address which now redirects should be validated, never submitted for indexing.

When this does not apply

Mostly this suits a site whose content survives the move. If you are shutting a site down, or the new one covers something else entirely, there is nothing honest to map. It also assumes you can set server-side redirects; on a host that allows only client-side ones, the order of preference in Google's documentation still holds, but the results are less certain. The script checks answers from one machine at one moment, so it cannot see a cache that answers differently by region, a rule that depends on a cookie, or a redirect that treats crawlers differently. It splits on plain commas, so URLs containing commas need handling that this version lacks. We ran no real migration for this text, and the script was not run against a live site while writing it. The advice comes from the three public documents cited in the text, all read on 26 November 2026, and Google revises its guidance now and then.

Read this post as Markdown: /blog/redirect-map-site-migration.md · Atom feed.