# Redirect Checker for Site Migrations: Chains, Loops, 301 vs 302 (`lightdata-tools/redirect-migration-validator`) Actor

Validate 301/302 redirects after a site migration. Per URL: status, hop chain, loops, final URL vs expected, canonical, title, H1, noindex. PASS/WARN/FAIL report.

- **URL**: https://apify.com/lightdata-tools/redirect-migration-validator.md
- **Developed by:** [LightData Tools](https://apify.com/lightdata-tools) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.30 / 1,000 url checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Redirect Checker for Site Migrations: Chains, Loops, 301 vs 302

Moving a website or changing URLs? Check that every old URL redirects to the right new page before and after launch. Paste old-to-new URL pairs, or give the old sitemap, and get a PASS / WARN / FAIL result for each URL.

### What it checks, per URL

- **Status code** of every hop (301, 302, 307, 308, 404, 5xx).
- **Redirect chains**: flags more than 1 hop, with the full chain listed.
- **Redirect loops** and chains over your hop limit.
- **Permanent vs temporary**: warns on 302/303/307 where a migration needs 301/308.
- **Final URL vs expected URL** (you can ignore query strings).
- **Final page**: HTTP status, `<title>`, first `<h1>`, canonical tag (and whether it matches the final URL), `noindex`.

### Input

Three ways, mix them freely:

1. `mappings`: `[{"oldUrl":"https://old.com/a","newUrl":"https://new.com/a"}]`
2. `oldUrls`: plain list, checked without an expected target.
3. `oldSitemapUrl` + `newBaseUrl`: reads the old sitemap and expects the same path on the new site.

### Output

- Dataset: one row per URL (export CSV, JSON, Excel from Console or API).
- `REPORT.csv` and `REPORT.md` in the key-value store: all rows, and only the problems.
- `SUMMARY`: counts of pass, warn, fail, loops, long chains, wrong final URLs, temporary redirects.

### Notes

- Title and H1 are read from the final page. The old page no longer exists after a redirect, so a before/after content diff needs the old content from you.
- Safety: requests to localhost, private networks and cloud metadata addresses are blocked (also when a redirect points there), and only ports 80, 443, 8080 and 8443 are used. Blocked, invalid and duplicate URLs are not charged.
- Sends normal GET requests with an identifiable user agent. Use low concurrency on small servers. Only check sites you own or are allowed to test.
- Cost: runs are light; about 1,000 URLs use a few cents of platform compute.

### API

```bash
curl -X POST "https://api.apify.com/v2/acts/lightdata-tools~redirect-migration-validator/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mappings":[{"oldUrl":"http://github.com","newUrl":"https://github.com/"}]}'
```

### Use cases

- SEO teams and agencies: QA every redirect before and after a site migration.
- Developers: add a redirect check to your release routine.
- Find chains, loops and 302s that should be 301s.
- Re-run weekly for a month after launch to catch regressions.

### Automate it (API, n8n, Make, Zapier)

Run it from any tool that can call a URL. Replace `YOUR_TOKEN` with your Apify API token (Console > Settings > API & Integrations).

```bash
curl -X POST "https://api.apify.com/v2/acts/lightdata-tools~redirect-migration-validator/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mappings":[{"oldUrl":"http://github.com","newUrl":"https://github.com/"}]}'
```

- **n8n**: add an "HTTP Request" node, method POST, the URL above, JSON body as shown. Or use the official Apify node and pick this Actor.
- **Make**: use the Apify app "Run an Actor" module (or HTTP "Make a request") with the same input.
- **Zapier**: use the Apify integration "Run Actor", or "Webhooks by Zapier" with a POST to the URL above.
- **Schedules**: in Apify Console, Schedules, create a daily or weekly run with your input.

# Actor input Schema

## `mappings` (type: `array`):

List of objects like {"oldUrl": "https://old.com/a", "newUrl": "https://new.com/a"}. The final URL after redirects is compared to newUrl.

## `oldUrls` (type: `array`):

Optional. URLs to check for status, chains, loops and final page without an expected target. Use full URLs with https://.

## `oldSitemapUrl` (type: `string`):

Optional. Sitemap (or sitemap index) of the OLD site, e.g. https://old.com/sitemap.xml. All its URLs are checked.

## `newBaseUrl` (type: `string`):

Optional, used with the old sitemap. Expected target = this base + the same path, e.g. https://new.com.

## `ignoreQuery` (type: `boolean`):

Compare final and expected URLs without ?query parts.

## `maxHops` (type: `integer`):

Stop and flag a chain longer than this.

## `timeoutSecs` (type: `integer`):

Timeout for each request.

## `concurrency` (type: `integer`):

URLs checked at once. Keep low for small sites.

## `maxUrls` (type: `integer`):

Safety cap for very large lists.

## Actor input object example

```json
{
  "mappings": [
    {
      "oldUrl": "http://github.com",
      "newUrl": "https://github.com/"
    },
    {
      "oldUrl": "http://apify.com",
      "newUrl": "https://apify.com"
    }
  ],
  "ignoreQuery": false,
  "maxHops": 10,
  "timeoutSecs": 15,
  "concurrency": 10,
  "maxUrls": 5000
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `reportCsv` (type: `string`):

No description

## `reportMd` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mappings": [
        {
            "oldUrl": "http://github.com",
            "newUrl": "https://github.com/"
        },
        {
            "oldUrl": "http://apify.com",
            "newUrl": "https://apify.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("lightdata-tools/redirect-migration-validator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "mappings": [
        {
            "oldUrl": "http://github.com",
            "newUrl": "https://github.com/",
        },
        {
            "oldUrl": "http://apify.com",
            "newUrl": "https://apify.com",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("lightdata-tools/redirect-migration-validator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mappings": [
    {
      "oldUrl": "http://github.com",
      "newUrl": "https://github.com/"
    },
    {
      "oldUrl": "http://apify.com",
      "newUrl": "https://apify.com"
    }
  ]
}' |
apify call lightdata-tools/redirect-migration-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,lightdata-tools/redirect-migration-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/qpXLzGjCbahf948JD/builds/fSfC6ObZnJbKBUcti/openapi.json
