Prompt to build a redirect map from old and new URLs
This prompt asks an AI assistant to match two URL lists, old and new, and write one redirect map in the format your host reads: vercel.json, _redirects, S3 routing rules or an Nginx map. It uses permanent redirects, avoids chains, flags unmatched URLs for you and writes a curl test script.
Last reviewed
Key facts
- Google recommends permanent redirects such as 301 and 308 and says to keep them for at least a year.
- Google says a chain should ideally have no more than 3 hops, and pointing straight at the final URL is better.
- Cloudflare Pages caps _redirects at 2,000 static and 100 dynamic rules, and Amazon S3 routing rules cap at 50.
- Test status: not tested yet. The curl loop was checked on live pages, and no real old and new URL lists were available.
The prompt
Paste this into Claude Code, Cursor, Gemini CLI or another AI coding assistant with your project folder open, and replace everything in square brackets first. See how to run it in each tool.
You are building a redirect map for a site move.
INPUT
- old-urls.txt: every URL of the old site, one per line.
- new-urls.txt: every URL of the new site, one per line.
- Host: [HOST: Vercel, Netlify, Cloudflare Pages, Amazon S3 or Nginx]
STEP 1: MATCH
Pair each old URL with its closest new URL. Use these in order: identical path, identical slug, same title, same topic. Write the pairs to MAP.csv with columns old, new, confidence (high, medium, low), reason.
STEP 2: RULES
- Use permanent redirects: 301, or 308 on Vercel.
- Send each old URL straight to its final URL in one hop. No chains.
- If no new page matches, do not send it to the home page. List it in UNMATCHED.md for me to decide between 404 and 410.
- Use one pattern rule instead of many lines when the pattern is clear and exact.
STEP 3: OUTPUT IN THE HOST FORMAT
- Vercel: redirects entries for vercel.json.
- Netlify: _redirects lines.
- Cloudflare Pages: _redirects lines with an explicit 301. Respect the limit of 2,000 static and 100 dynamic rules.
- Amazon S3: routing rules (maximum 50) plus a list of per-object redirects for the rest.
- Nginx: a map block and a server-level return 301 $new_uri line.
STEP 4: TEST SCRIPT
Write test-redirects.sh that requests each old URL with curl and prints the status code and Location header.
Ask me before you guess any low-confidence match.How to run it
- Export both URL lists. The sitemap of the old site and of the new preview are the easiest sources.
- Send the prompt with your host filled in, and read MAP.csv first, starting with the low-confidence rows.
- Decide every row in UNMATCHED.md, then ask the assistant to produce the host file.
- Deploy to a preview address and run the test script before you switch DNS.
Where each host reads redirects
| Host | File or setting | Limit to know |
|---|---|---|
| Vercel | redirects in vercel.json | Bulk redirects are a separate setting for Pro and Enterprise |
| Netlify | _redirects or netlify.toml | _redirects rules run before netlify.toml rules |
| Cloudflare Pages | _redirects | 2,000 static, 100 dynamic, default status 302 |
| Amazon S3 | Website routing rules, or object redirect metadata | 50 routing rules per website configuration |
| Nginx | map and return in the config | Reload after each change |
Verify the result
Run the test script against the preview address. Each old URL should answer with a 301 or 308 and a Location header that points at the final URL, and that URL should answer 200.
while read -r old; do
curl -s -o /dev/null -w "$old %{http_code} %{redirect_url}\n" "https://preview.example.com$old"
done < old-paths.txt- No old URL answers 200 or 404 unless you chose that on purpose.
- No Location header points at another redirect.
- Every rule matches the limits for your host.
What can go wrong
- Redirecting every unmatched URL to the home page. List them and decide between 404 and 410 for each.
- A low-confidence match that sends visitors to the wrong page. Review those rows yourself.
- A pattern rule that is too broad and catches pages that should stay. The test script catches it.
Frequently asked questions
Should I use 301 or 308?
Either. Google recommends permanent redirects such as 301 and 308. Vercel sends a 308 when you set permanent to true.
How long should the redirects stay?
Google says to keep them as long as possible, generally at least a year.
Can a tool build the first draft?
Yes. The Redirect Map Builder builds an old to final mapping from URL lists, and the prompt can then refine it.
Where do I read about each host?
See the host guides for the exact files on Vercel, Netlify, Cloudflare Pages, Amazon S3 and Nginx.
Official documentation
Free tools for this job
- Redirect Map BuilderBuild an old-to-final redirect mapping from URL lists.
- Canonical Chain AuditorAudit canonical tags against redirect chains and final resolved URLs.
- Broken Link CheckerScan sitemap or URL lists and report broken links with HTTP status insights.
- Sitemap URL ExtractorExtract all <loc> URLs from sitemap files, including sitemap index files.
Start with the files
Prompts work best on a WebExport download of your site. Paste your public URL into the export form and get a ZIP. The Free plan covers 1 site, 5 exports a month, 15 pages and 20 MB per export. Professional is a $9.99 one-time purchase with unlimited pages.