Skip to content

Import, export and commands

phil/redirects-bundle

The CSV format

One redirect per line, after a header that names the columns, in any order:

source,target,status,kind,host,query,locale,enabled,hits,last_hit_at
/old/page,/new/page,301,exact,,drop,,1,12,2026-05-01T10:00:00+00:00
/docs,/manual,301,prefix,,keep,,1,0,
/blog/*/**,route:blog_post?slug=$1,308,wildcard,www.example.com,drop,fr,1,0,
/removed,,410,exact,,drop,,1,0,
ColumnDefault when missing or blank
sourcerequired
targetnone (for a 410)
status301
kindexact
hostevery host
querydrop
localeevery locale
enabledenabled; 0, false, no or off disable
hits, last_hit_atwritten on export, ignored on import

A byte-order mark is ignored, an unknown column too. Every line goes through the checks of a save — a source already there is skipped, or updated with --update; the earlier lines count for the later ones. A refused line is reported with its line number and its reason, and the others are imported.

Commands

CommandDoes
phil:redirects:import <file> [--update] [--dry-run]Imports a CSV file; fails when a line was refused.
phil:redirects:export [file]Writes every redirect as CSV, to the file or to the standard output.
phil:redirects:checkLists the stored redirects the checks would refuse today; fails when there is one.
phil:redirects:purge-404 [--older-than=DAYS]Removes the paths not requested for retention days, or the days given.

The console imports regular expressions when they are enabled; the administration's import never does.