Skip to content

Console Commands

All commands are available via ddev php craft (or php craft outside DDEV).

Export and import commands support stdin and stdout for piping. This makes them useful for scripting, CI/CD pipelines, and AI agent workflows:

bash
# Pipe 404 export to another tool
php craft not-found-redirects/not-found-uris/export - --format=json | jq '.[] | select(.hitCount > 10)'

# Import from stdin
cat redirects.csv | php craft not-found-redirects/redirects/import - --format=csv

404s

Export

Export all 404 records.

bash
php craft not-found-redirects/not-found-uris/export
path: string
File path to write to, or `-` for stdout. Defaults to `-`.
--format: csv|json
File format override. Inferred from file extension if omitted. Defaults to json for stdout.

Import

Import 404 records from a CSV or JSON file, or stdin.

bash
php craft not-found-redirects/not-found-uris/import
path: string
Path to the CSV or JSON import file. Use `-` to read from stdin.
--format: csv|json
File format override. Auto-detected from file extension or content if omitted.
--source: native|retour
Data source. Auto-detected from column headers if omitted.

Reprocess

Reprocess unhandled 404s against enabled redirect rules.

bash
php craft not-found-redirects/not-found-uris/reprocess

Purge

Purge stale 404 records older than the given threshold.

bash
php craft not-found-redirects/not-found-uris/purge
lastSeen: string
Purge cutoff — any strtotime()-compatible value (e.g. "-90 days").

Reset Hit Counts

Reset hit counts to zero for all 404s and referrers.

bash
php craft not-found-redirects/not-found-uris/reset-hit-counts

Redirects

Export

Export all redirect rules.

bash
php craft not-found-redirects/redirects/export
path: string
File path to write to, or `-` for stdout. Defaults to `-`.
--format: csv|json
File format override. Inferred from file extension if omitted. Defaults to json for stdout.

Import

Import redirect rules from a CSV or JSON file, or stdin.

bash
php craft not-found-redirects/redirects/import
path: string
Path to the CSV or JSON import file. Use `-` to read from stdin.
--format: csv|json
File format override. Auto-detected from file extension or content if omitted.
--source: native|retour
Data source. Auto-detected from column headers if omitted.

Retour Migration

Migrate All

Migrate both 404 stats and redirect rules from Retour's database tables.

bash
php craft not-found-redirects/migrate/retour

Migrate 404s

Migrate 404 stats from Retour's retour_stats table.

bash
php craft not-found-redirects/migrate/retour-404s

Migrate Redirects

Migrate static redirect rules from Retour.

bash
php craft not-found-redirects/migrate/retour-redirects