Disclosure: I built the Apify Actor mentioned in the second half and earn money when people run it. Everything in the first half is free and uses only Python's standard library.
The most common way a redesign or platform move loses search traffic is boring: old URLs that used to rank now return 404, or all redirect to the homepage. Nobody notices for weeks, because the new site looks fine.
The fix is also boring, and it has to start before launch: save a list of every URL the old site has, then after launch check that each one redirects to the right new page. The old site's sitemap is the easiest source for that list, and once the old site is gone, so is its sitemap.
Step 1 (before launch): save every URL from the old sitemap
Most sites list their sitemap in robots.txt. WordPress, Shopify, Wix and Squarespace all publish one, often as an index that points to several child sitemaps. This script follows the index and writes every URL to a CSV:
import csv import gzip import urllib.request import xml.etree.ElementTree as ET NS = "{http://www.sitemaps.org/schemas/sitemap/0.9}" UA = {"User-Agent": "Mozilla/5.0 (sitemap export)"} def fetch(url): with urllib.request.urlopen(urllib.request.Request(url, headers=UA), timeout=30) as r: body = r.read() return gzip.decompress(body) if body[:2] == b"\x1f\x8b" else body def sitemap_urls(sitemap_url, depth=0): root = ET.fromstring(fetch(sitemap_url)) if root.tag == NS + "sitemapindex" and depth < 3: for loc in root.iter(NS + "loc"): yield from sitemap_urls(loc.text.strip(), depth + 1) else: for u in root.iter(NS + "url"): yield u.findtext(NS + "loc", "").strip(), u.findtext(NS + "lastmod", "") rows = list(sitemap_urls("https://wordpress.org/news/sitemap.xml")) with open("old_urls.csv", "w", newline="") as f: w = csv.writer(f) w.writerow(["url", "lastmod"]) w.writerows(rows) print(len(rows), "URLs saved") Run it on the live site, keep old_urls.csv with the project files, and you have your "before" list. If you don't know the sitemap URL, look for a Sitemap: line in https://yoursite.com/robots.txt.
Where this script stops: sitemaps with a stray & or a missing closing tag (common with plugins) make ElementTree give up, plain-text and RSS sitemaps need their own parsing, and a site without a Sitemap: line needs you to guess the location.
Step 2 (after launch): check where every old URL lands
import csv import urllib.error import urllib.request UA = {"User-Agent": "Mozilla/5.0 (redirect check)"} def land(url): req = urllib.request.Request(url, headers=UA, method="HEAD") try: with urllib.request.urlopen(req, timeout=20) as r: # follows redirects return r.status, r.geturl() except urllib.error.HTTPError as e: return e.code, e.geturl() except OSError as e: return None, str(e) with open("old_urls.csv") as f: old = [row["url"] for row in csv.DictReader(f)] with open("migration_check.csv", "w", newline="") as f: w = csv.writer(f) w.writerow(["old_url", "status", "final_url", "verdict"]) for url in old: status, final = land(url) if status is None or status >= 400: verdict = "BROKEN" elif final.rstrip("/") == url.rstrip("/"): verdict = "same URL" elif final.rstrip("/").count("/") <= 2: verdict = "CHECK: lands on homepage" else: verdict = "redirected" w.writerow([url, status, final, verdict]) if verdict not in ("same URL", "redirected"): print(verdict, url, "->", final) Sort migration_check.csv by verdict. BROKEN rows need a redirect. lands on homepage rows are the quiet ones: a blanket "send everything to /" rule technically redirects, but search engines treat it like a 404 for the old page. Point each one at its closest new page instead.
Here's what it gives for a few real URLs today (13 November 2026), as an example of each kind of result:
| old_url | status | final_url | verdict |
|---|---|---|---|
| http://wordpress.org/news/ | 200 | https://wordpress.org/news/ | redirected |
| https://python.org/about/ | 200 | https://www.python.org/about/ | redirected |
| https://wordpress.org/news/toc/ | 200 | https://wordpress.org/news/files/2023/06/TOC.mov | redirected |
| https://wordpress.org/news/this-page-does-not-exist-2026/ | 404 | (same) | BROKEN |
Step 1 on the wordpress.org news sitemap saved 2,618 URLs in a few seconds. The third row is a real oddity: an old attachment page that now redirects straight to a video file. Technically "redirected", but worth a look.
The hosted version, for big sites or sites you don't control
The scripts above are fine for a few hundred URLs on your own site. I built an Apify Actor for the parts that get fiddly: it finds the sitemaps on its own (robots.txt plus the usual locations, .gz files, plain-text and RSS sitemaps), survives broken XML, and can check every URL's status and redirect target in the cloud, a few at a time so it doesn't hammer the server.
Two ways it helps a migration:
- Before launch: paste the old domain and export the URL list (about $0.20 per 1,000 URLs).
- After launch: run it on the new site with Check each URL's status and Only output problem URLs on, to make sure the new sitemap lists only live, final URLs (about $1 per 1,000 URLs checked).
It checks the URLs in a sitemap, not every link inside your pages, so for step 2 above (old URLs that are no longer in any sitemap) keep using the script.
Its page: apify.com/zahidthani/sitemap-url-extractor-status-checker. A free Apify account includes $5 of usage a month, which covers about 25,000 URLs listed.
Runnable Python, Node.js and n8n examples: https://github.com/zahidthani/apify-data-tools-examples
On the wordpress.org news sitemap (first 150 URLs, run on 9 November 2026), it found 146 OK and 4 entries that redirect to video files, the kind of leftover that's worth cleaning out of a sitemap during a move anyway.
Checklist
- Export the old URL list before the old site goes away (sitemap, plus your analytics top pages).
- Map old to new URLs in a spreadsheet; one-to-one where you can.
- Use 301 redirects, not 302, and avoid chains (old → older → new).
- After launch, run step 2 and fix every
BROKENandlands on homepagerow. - Submit the new sitemap in Google Search Console and watch the Pages report for a few weeks.
Questions about a specific migration (Shopify to WooCommerce, Wix to WordPress...) are welcome in the comments.