Building a redirect map from two URL lists

How to gather and clean old and new URL lists, match them, review the weak pairs and export a redirect map your web server can actually use.

A redirect map is a simple thing: a table with old URLs in one column and new URLs in the other. Every row becomes a 301 redirect on the new site. Building it is where most of the work in a site move happens, and where most mistakes creep in.

This post covers the practical side: where the two lists come from, how to clean them so they match properly, how to review the pairs, and how to turn the finished map into rules your server can use.

Gather the old list

The old list should hold every URL on the current site that a visitor or search engine might request. Combine several sources, because each one misses something:

  • A crawl of the live site, which finds pages linked from other pages.
  • The current sitemap.xml, which may include pages the crawl did not reach.
  • URLs from the Pages and Performance reports in Google Search Console.
  • Landing pages from your analytics, especially ones with visits from other websites.

Our website crawler is a good starting point, as its report lists every URL it found with its status code. Keep only the URLs that currently work (status 200). Anything that already redirects is handled separately, and pages that already return 404 do not need a new destination.

Gather the new list

The new list is every URL the new site will have. On a redesign you can usually crawl the staging site, as long as it is reachable and not blocked by robots.txt. On a platform change, most systems can export a list of pages, posts, products and categories. If neither is possible, the new site's sitemap will often do.

Make sure the new list uses the addresses that will be live, not staging ones. If staging runs at staging.example.com, swap that for the live hostname before you match anything.

Clean both lists before matching

Most poor matches come from lists in different formats rather than from genuinely hard pages. Spend ten minutes on these first:

  1. Use one format. Either full URLs in both lists or paths only in both.
  2. Remove duplicates, including the same page listed with and without a trailing slash.
  3. Strip tracking parameters such as utm_source that came in from analytics exports. They are not separate pages.
  4. Keep meaningful query strings, such as ?id=42 on an old product page, because those really do identify different content.
  5. Drop assets such as images, stylesheets and scripts unless you have a specific reason to redirect them.

Match, then review

With clean lists, paste the old URLs into one box and the new URLs into the other in the redirect mapper. It works through three passes. First it pairs URLs with the same path, which covers pages that have not moved at all. Next it pairs URLs with the same slug, the last part of the address, which catches pages that moved into a new folder. Finally it pairs URLs whose words are similar, for pages that were renamed slightly. Each pair gets a confidence level, and everything runs in your browser.

The review is the part that matters. Work through the list in this order:

  • Low confidence matches. Open both pages if you need to. Similar words do not always mean similar content.
  • Unmatched old URLs. For each one, find the closest real replacement. If there is none, leave it out of the map and let it return 404 or 410 rather than forcing it onto an unrelated page.
  • Many to one. Several old pages pointing to one new page is fine when content has been merged. Check that the new page really covers what each old one did.
  • High value pages. Check your most visited and most linked pages by hand, whatever their confidence score.

Edit any pair directly in the tool until the map says what you mean it to say.

Export and put it live

When the map is right, export it in the format your site needs:

  • .htaccess for Apache hosting. The export writes exact match mod_rewrite 301 rules and handles query strings.
  • nginx map for servers running nginx, ready to include in your configuration.
  • CSV for CMS redirect plugins and platforms that import redirects from a spreadsheet.

Keep a copy of the final map with your project files. It is the reference you will need later if someone asks why a page redirects where it does.

Before launch, look for any destination that is itself an old URL in the map. If page A points to page B, and page B also redirects, you have built a chain. Point A straight at the final address instead. For the wider sequence of steps around this, see planning a website move without losing search traffic.

Your next step

Start with the old list, because it can only be built while the current site is still live. Crawl the site today, add your sitemap and Search Console URLs, and clean the result. When the new site's URLs are ready, paste both lists into the redirect mapper and work through the review. A map you have checked row by row is the most reliable protection a move can have.