# Domain Migration

> Plan and validate an SEO site move with a URL inventory, redirect map, canonical cutover and backlink-update drafts.

- Skill: `ranbot-ai/domain-migration-2` (Agent Skill)
- Install (CLI): `npx get-skill add ranbot-ai/domain-migration-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ranbot-ai/domain-migration-2/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: ranbot-ai (https://skillmd.com/u/ranbot-ai)
- Updated: 2026-12-03
- Page: https://skillmd.com/skills/ranbot-ai/domain-migration-2

---

---
name: domain-migration
description: Plan and validate an SEO site move with a URL inventory, redirect map, canonical cutover and backlink-update drafts. 
category: Business & Marketing
source: antigravity
tags: [node, ai, llm, template, rag, seo, cro, marketing]
url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/domain-migration
---


# Domain Migration

## When to Use

Use when changing a site's domain, consolidating slugs or moving a subdomain into a folder. Produce a URL inventory, permanent redirect map, cutover changes, verification results and optional outreach drafts. The examples use illustrative hosts.

Work on a branch or staging environment. Record the starting analytics and crawl state, affected hosts, activation order and rollback procedure. Require explicit authority before changing DNS, deploying to production, submitting Change of Address or sending mail.

## Decision tree: which migration is this

```
Migration type
├── Full domain change (billbox.io → invoicekit.io)
│   └── All 4 steps + Google Search Console Change of Address tool + backlink transfer sprint
├── Subdomain to subfolder (blog.deployfast.dev → deployfast.dev/blog)
│   └── Steps 1-3. Backlink sprint only for the top 10 referring pages to the subdomain.
├── Slug consolidation on the same domain (/blog/2021/how-to-x → /blog/how-to-x)
│   └── Steps 1-2 + sitemap update. No Change of Address.
└── Merging 2 sites into 1
    └── All 4 steps for the retired site. Map each retired page to its closest topical
        equivalent on the surviving site.
```

## Step 1: Full URL inventory

Build the union of every source below. Each catches URLs the others miss.

1. **Old `sitemap.xml`** (and nested sitemaps): the URLs the site currently advertises.
2. **Repo route tree:** every static route plus every slug generated by dynamic routes (`content/**`, data files, CMS export).
3. **Google Search Console:** Pages report, last 16 months, every URL with at least 1 click or 10 impressions.
4. **Ahrefs Best by links** (or the backlink tool the user has): every old URL with at least 1 referring domain. This is the list that saves retired posts with strong backlinks.
5. **Analytics landing pages:** every landing page with at least 1 session in the last 12 months.

Normalize before deduping: lowercase host, strip query strings and fragments, and pick one trailing-slash form. Write the result to `seo/url-inventory.csv` with columns `old_url,source,clicks_16mo,referring_domains`.

## Step 2: Deterministic 1-to-1 redirect map

Assign every inventory row a destination:

```
Old URL
├── Same content, same path on the new domain
│   └── Map the exact path
├── Same content, new slug
│   └── Explicit 1-to-1 entry
├── Content merged into another page
│   └── Explicit entry to the page that absorbed it
├── Content deleted, has referring domains or clicks
│   ├── A page on the same topic exists → explicit entry to that page
│   └── No topical equivalent → restore the page on the new domain, then map it 1-to-1
└── Content deleted, 0 referring domains, 0 clicks
    └── Let it return 410. Never point it at the homepage.
```

Then collapse chains: if the site already has redirects (`/old-slug → /new-slug`), resolve every entry to its final destination so each old URL reaches its target in exactly 1 hop.

Write `seo/redirect-map.csv` with header `old_url,new_url`. Every `new_url` must return `200` on the new domain before cutover.

### Ship the config for the user's host

**Next.js** (`next.config.mjs` on whichever deployment answers the old host). `permanent: true` returns `308`, which Google treats the same as `301`.

```js
import { readFileSync } from 'node:fs'

const explicit = readFileSync('./seo/redirect-map.csv', 'utf8')
  .trim().split('\n').slice(1)
  .map((line) => line.split(','))
  .map(([oldUrl, newUrl]) => ({ from: new URL(oldUrl).pathname, to: newUrl }))

export default {
  async redirects() {
    return [
      // Explicit 1-to-1 entries first: Next.js uses the first matching rule.
      ...explicit.map(({ from, to }) => ({
        source: from,
        has: [{ type: 'host', value: '(www\\.)?billbox\\.io' }],
        destination: to,
        permanent: true,
      })),
    ]
  },
}
```

Escape `(`, `)`, `:`, `*`, and `?` in old paths before using them as `source`; Next.js parses those characters as pattern syntax.

**Cloudflare Bulk Redirects** (CSV upload to a Bulk Redirect List, then enable a Bulk Redirect Rule for it):

```csv
source_url,target_url,status_code,preserve_query_string,include_subdomains,subpath_matching,preserve_path_suffix
billbox.io/blog/2021/send-invoices-faster,https://invoicekit.io/blog/send-invoices-faster,301,true,false,false,false
billbox.io/,https://invoicekit.io/,301,true,false,false,false
```

The last row matches the homepage only. Scope each rule to approved subdomains.

**Nginx:**

```nginx
map $uri $redirect_target {
  default "";
  include /etc/nginx/billbox-redirects.conf;  # lines like: /blog/2021/send-invoices-faster https://invoicekit.io/blog/send-invoices-faster;
}

server {
  listen 80;
  listen 443 ssl;
  server_name billbox.io www.billbox.io;
  # ssl_certificate lines stay: the old domain must keep valid HTTPS to serve its redirects.

  if ($redirect_target) { return 301 $redirect_target$is_args$args; }
  return 404;
}
```

Both listeners 

