Skip to main content

redirect add

Destructive

This command adds redirect rules to your database. Use --dry-run to preview.

Usage

seo-ops redirect add <from> <to> [--type=301|302] [--path=<path>] [--dry-run]

Add a redirect rule. Works with Redirection plugin or Rank Math SEO.

Examples

Add 301 Redirect

seo-ops redirect add /old-page /new-page --path=/var/www/html

Output:

Redirect added: /old-page → /new-page (301)

Add 302 Redirect (Temporary)

seo-ops redirect add /promo /new-promo --type=302 --path=/var/www/html

Output:

Redirect added: /promo → /new-promo (302)

Preview Only

seo-ops redirect add /old /new --path=/var/www/html --dry-run

Output:

DRY RUN: Would add redirect /old → /new (301)
No database changes were made.

Exit Codes

CodeMeaning
0Success
1Invalid redirect type or duplicate detected
2Missing argument
4WordPress path not configured