# Redirect Checker (`luck777/redirect-checker`) Actor

Follows redirect chains for one or more URLs and reports every hop — status code, Location header, and server info — to the final destination.

- **URL**: https://apify.com/luck777/redirect-checker.md
- **Developed by:** [Luck Vergouwen](https://apify.com/luck777) (community)
- **Categories:** SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

Traces the full redirect chain for one or more URLs and reports every hop — HTTP status code, `Location` header, `Server`, and `X-Powered-By` — all the way to the final destination.

Built on the lightweight `apify/actor-node:22` base image. No browser required.

***

### Use cases

- **SEO audits** — find unnecessary redirect chains (301 → 302 → 200) that waste link equity and slow page load
- **URL migration checks** — verify that old URLs redirect correctly to new ones after a site restructure
- **Short-link analysis** — unpack bit.ly, t.co, or custom short links to see the full chain before clicking
- **Security research** — detect malicious redirect chains or open redirectors
- **Infrastructure debugging** — confirm that CDN, load balancer, or proxy redirects behave as expected
- **Third-party link monitoring** — track whether affiliate or partner redirect chains change over time

***

### Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `urls` | `string[]` | Yes | — | List of URLs to trace |
| `maxRedirects` | `integer` | No | `20` | Max hops per URL before stopping |
| `timeout` | `integer` (ms) | No | `10000` | Per-request timeout in milliseconds |

#### Example input

```json
{
    "urls": [
        "https://bit.ly/3example",
        "http://example.com",
        "https://t.co/abc123"
    ],
    "maxRedirects": 20,
    "timeout": 10000
}
```

***

### Output

One dataset record per input URL.

| Field | Type | Description |
|---|---|---|
| `url` | `string` | The original input URL |
| `finalUrl` | `string \| null` | The last URL reached in the chain |
| `totalRedirects` | `number` | Number of redirect hops (0 = no redirect) |
| `chain` | `object[]` | Full list of hops (see below) |
| `isLoop` | `boolean` | `true` if a redirect loop was detected |
| `error` | `string \| null` | Error message if something went wrong, otherwise `null` |

#### Chain hop object

| Field | Type | Description |
|---|---|---|
| `url` | `string` | URL of this hop |
| `statusCode` | `number \| null` | HTTP status code (e.g. `301`, `302`, `200`), or `null` on network error |
| `location` | `string \| null` | Value of the `Location` response header |
| `server` | `string \| null` | Value of the `Server` response header |
| `xPoweredBy` | `string \| null` | Value of the `X-Powered-By` response header |

#### Example output record

```json
{
    "url": "http://example.com",
    "finalUrl": "https://www.example.com/",
    "totalRedirects": 2,
    "chain": [
        {
            "url": "http://example.com",
            "statusCode": 301,
            "location": "https://example.com/",
            "server": "ECAcc (nyb/1D2E)",
            "xPoweredBy": null
        },
        {
            "url": "https://example.com/",
            "statusCode": 302,
            "location": "https://www.example.com/",
            "server": "ECAcc (nyb/1D2E)",
            "xPoweredBy": null
        },
        {
            "url": "https://www.example.com/",
            "statusCode": 200,
            "location": null,
            "server": "ECAcc (nyb/1D2E)",
            "xPoweredBy": null
        }
    ],
    "isLoop": false,
    "error": null
}
```

***

### Redirect status codes tracked

| Code | Meaning |
|---|---|
| 301 | Moved Permanently |
| 302 | Found (temporary redirect) |
| 303 | See Other |
| 307 | Temporary Redirect |
| 308 | Permanent Redirect |

Any other status code (200, 404, 500, etc.) is treated as the final destination and ends the chain.

***

### Error handling

- **Timeout** — if a hop exceeds `timeout` ms, the chain stops and `error` is set to `"Request timed out after Xms"`
- **DNS / network failure** — the chain stops and `error` describes the failure
- **Malformed Location header** — the chain stops and `error` describes the bad header
- **Redirect loop** — detected when a URL appears twice in the chain; `isLoop` is set to `true`
- **Max redirects exceeded** — the chain stops after `maxRedirects` hops; `error` is `null` but `totalRedirects` will equal `maxRedirects`
- **Invalid input URL** — a record is written immediately with `error` set and an empty `chain`

***

### Pricing

This actor uses **pay-per-event** billing via the Apify platform. One credit is charged per URL checked (`url-checked` event), regardless of how many hops the chain contains.

***

### Technical notes

- Uses native `fetch()` with `redirect: 'manual'` — no browser, no Playwright, no Puppeteer
- Runs on the minimal `apify/actor-node:22` Docker image for fast cold starts
- Relative `Location` headers are resolved against the current URL using the WHATWG `URL` API
- ES module (`"type": "module"`) with top-level `await`

# Actor input Schema

## `urls` (type: `array`):

List of URLs to check for redirects. Each URL will be followed to its final destination.

## `maxRedirects` (type: `integer`):

Maximum number of redirect hops to follow per URL before stopping. Prevents infinite loops.

## `timeout` (type: `integer`):

Maximum time in milliseconds to wait for each individual HTTP request.

## Actor input object example

```json
{
  "urls": [
    "https://bit.ly/3example",
    "http://example.com"
  ],
  "maxRedirects": 20,
  "timeout": 10000
}
```

# Actor output Schema

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

Redirect chain data for each URL including hops, status codes, and final destination.

# 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 = {
    "urls": [
        "https://bit.ly/3example",
        "http://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("luck777/redirect-checker").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 = { "urls": [
        "https://bit.ly/3example",
        "http://example.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("luck777/redirect-checker").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 '{
  "urls": [
    "https://bit.ly/3example",
    "http://example.com"
  ]
}' |
apify call luck777/redirect-checker --silent --output-dataset

```

## MCP server setup

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

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/ggT7icsi1n8EQdtpW/builds/DWR3scMGdir7uIyE6/openapi.json
