← Back to writing

Article · web / python / redirects

Will old links reach the new page?

Check a simple CSV redirect plan for chains, cycles and conflicting rules offline before deployment, then verify the live HTTP behavior separately.

Imagine reorganizing the content of a small website. An old guide lived at /old-guide. We collected guides under /guides, then renamed that section /learn. Someone reviewing the mapping file might see two reasonable rows. Read together, they show that an old link passes through two redirects.

This is a synthetic example, not a customer incident. The everyday question is still useful: where do individually sensible migration decisions take the visitor when combined? If one path points back to an earlier path, there may be no final page in the map at all.

Read the rows together

csv
from,to,status
/old-guide,/guides,301
/guides,/learn,308

The map traces /old-guide -> /guides -> /learn. A two-hop chain is not automatically wrong, but it deserves review. If the intent is to send the old content to one new page, is the intermediate stop needed? Having no rule for /learn in the file does not establish that the page exists.

Now imagine adding a rule from /learn back to /old-guide. That creates a three-node cycle. A different problem occurs when the same source has competing destinations: if /old-guide points to both /guides and /archive, we cannot choose which rule a server would apply from this file. The same target with both 301 and 302 is also a conflict.

Check the plan before applying it

Google's site-move guide includes mapping old URLs to new ones as part of migration preparation. Redirect Map Check is a small Python tool I prepared for a narrow part of that plan: simple paths on the same site, before the mapping has been applied to a server.

It reads a local CSV and separately reports identical duplicates, target/status conflicts, self-redirects, multi-node cycles and chains. It never selects the first or last conflicting rule. Routes reaching a conflicted source stop there, with the relevant line numbers available for review.

Its place alongside existing options

A small spreadsheet can be reviewed by hand or traced as a graph with a script. Once real addresses are available, tools such as Screaming Frog SEO Spider's redirect audit crawl URLs and report observed redirects. That is a distinct and necessary stage beyond reading an offline CSV plan.

Redirect Map Check does not claim to replace those tools or invent a new kind of audit. It offers a small starting point when I want to inspect a mapping file before applying it, without a network connection. It knows nothing about server rule precedence, domain changes or rules omitted from the map.

A practical run

Download the MIT-licensed ZIP or review the source on GitHub. Extract it and run Python inside the redirect-map-check folder; no package installation is required. Start with the included example:

text
python -B redirect_map_check.py examples/chain.csv --lang en
python -B redirect_map_check.py examples/mixed.csv --format json

The first command reports two hops from /old-guide and the final path /learn. Reachability explicitly remains “not verified.” Its exit code is 1 because a chain was found. Exit 0 means no map findings within this limited scope; 2 means invalid or unsupported input; 3 indicates a file read/type error. The source CSV is unchanged. There is no automatic repair or server configuration output.

Version one accepts only simple root-relative ASCII paths starting with / and status codes 301, 302, 307 and 308. Full URLs, query strings, fragments, encoded paths, wildcards and regex are rejected. Case and trailing slashes remain distinct. The limits are 2 MiB per file, 2,000 data records and 512 characters per path; the README defines the full grammar and physical-line limit. One unsupported record prevents a partial clean report.

The source and extracted ZIP independently passed 45/45 synthetic tests. The test scope and command are documented in the package's QA.md. This does not mean that a live site was tested. The tested platform was CachyOS with Python 3.14.9; Windows and macOS were not tested.

Observe HTTP after deployment too

MDN's redirection guide explains HTTP redirects through response status codes and the Location header. A CSV does not observe those responses. After applying the map, check actual old URLs in an authorized environment, follow each step, and inspect the final response and expected content.

Domain and HTTPS rules, CDN or application behavior, slash transformations and request-method preservation where relevant need separate review. A terminal path in the map can return 404, serve the wrong content, or encounter an omitted rule that creates another cycle. The local check helps us begin that live review with a more orderly plan. It cannot guarantee reachability, rankings or security.

← Back to writingmuhammet.saridogan.work@gmail.com