← Back to all products
$19
Redirect Mapper
URL redirect mapping tool with chain detection, status code validation, and SEO impact analysis.
JSONMarkdownPythonCI/CD
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 10 files
redirect-mapper/
├── LICENSE
├── README.md
├── examples/
│ ├── redirects.csv
│ └── redirects.json
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_input-formats.md
│ └── 03_license.md
├── index.html
└── src/
└── redirect_mapper.py
📖 Documentation Preview README excerpt
Redirect Mapper
Part of the SEO Toolkit by CodeVault
Validate your redirect maps before deploying them. Detect loops, chains, status code mistakes, protocol mismatches, and self-referencing redirects — all the things that tank rankings during site migrations.
Features
- Load redirect rules from CSV or JSON files
- Detect redirect loops (A → B → A) before they hit production
- Find redirect chains (A → B → C → D) and warn about depth
- Validate HTTP status codes (301 vs 302 vs 307/308)
- Catch protocol downgrades (HTTPS → HTTP)
- Flag trailing slash inconsistencies
- Detect self-referencing redirects
- Multiple output formats: text, CSV, or JSON report
- Configurable max chain depth
- Strict mode for CI/CD pipelines
- Python stdlib only — zero dependencies
Quick Start
# Validate a CSV redirect map
python src/redirect_mapper.py --input examples/redirects.csv
# Validate a JSON redirect map
python src/redirect_mapper.py --input examples/redirects.json
# Get JSON output for CI/CD
python src/redirect_mapper.py --input examples/redirects.csv --format json
# Strict mode — fail on any warning
python src/redirect_mapper.py --input examples/redirects.csv --strict
# Custom max chain depth
python src/redirect_mapper.py --input examples/redirects.csv --max-depth 5
# Write report to file
python src/redirect_mapper.py --input examples/redirects.csv --output report.txt
Input Formats
CSV Format
old_url,new_url,status_code
https://www.example.com/old-page,https://www.example.com/new-page,301
https://www.example.com/temp-page,https://www.example.com/other,302
JSON Format
[
{"old_url": "https://www.example.com/old-page", "new_url": "https://www.example.com/new-page", "status_code": 301},
{"old_url": "https://www.example.com/temp-page", "new_url": "https://www.example.com/other", "status_code": 302}
]
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
src/redirect_mapper.py
#!/usr/bin/env python3
"""
Redirect Mapper — SEO Toolkit by DataNest
Check HTTP redirect chains, detect loops, validate status codes, and
generate redirect maps for site migrations. Feed it a CSV or JSON of
redirect rules and get a full health report before you flip the switch.
Why this exists:
Site migrations are the #1 cause of SEO disasters. A single redirect
loop or a chain that's too deep will tank your rankings overnight.
This tool validates your redirect map BEFORE you deploy it — catching
loops, chains, status code mistakes, and protocol mismatches that
would otherwise take weeks to debug in production.
Usage:
python redirect_mapper.py --input redirects.csv
python redirect_mapper.py --input redirects.json --format json
python redirect_mapper.py --input redirects.csv --max-depth 5 --strict
License: MIT
"""
from __future__ import annotations
import argparse
import csv
import json
import logging
import sys
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
from urllib.parse import urlparse
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
# Google follows up to 10 redirects before giving up
MAX_REDIRECT_DEPTH = 10
# Valid redirect status codes and their meanings
REDIRECT_STATUS_CODES: dict[int, str] = {
301: "Moved Permanently (pass link equity)",
302: "Found (temporary — does NOT pass full link equity)",
303: "See Other (temporary)",
307: "Temporary Redirect (preserves request method)",
308: "Permanent Redirect (preserves request method)",
}
# ... 495 more lines ...