Redirection provides a limited set of WP CLI commands:
wp redirection import– import from a filewp redirection export– export to a filewp redirection database– install or upgrade a sitewp redirection setting– set or get a Redirection settingwp redirection plugin– import from other plugins
Note that all actions are available for single or multi site using the appropriate WP CLI parameter.
Importing
You can import CSV, JSON, or .htaccess files using WP CLI. The format is:
wp redirection import <filename> --format=<format>
Where <format> is one of:
csvapachejson
Exporting
You can export to CSV, JSON, .htaccess, or Nginx format files using WP CLI. The format is:
wp redirection export <module> <filename> --format=<format>
Where --format is one of:
csvapachejsonnginx
And <module> is one of:
all– all Redirection moduleswordpressapachenginx
Database
You can perform Redirection database actions using WP CLI. The format is:
wp redirection database <action>
Where <action> is one of:
install– Install the Redirection database tablesremove– Remove the Redirection database tablesupgrade– Upgrade the Redirection database tables to the latest version
Settings
You can get or set Redirection options using WP CLI. The format is:
wp redirection setting <name>
Where <name> is the setting name.
You can update a setting with:
wp redirection setting <name> --set=[value]
The value should be in JSON format if it is anything other than a string or number.
Note that the value will be validated according to the setting.
Plugin Import
You can import redirects from any supported plugin. The format is:
wp redirection plugin <name> [--group=ID]
Where <name> is the plugin name:
wp-simple-redirectseo-redirectionsafe-redirect-managerwordpress-old-slugsrank-mathquick-redirects
An optional group ID can be supplied, otherwise the redirects will be imported into the first group.