1006 B
1006 B
Safe wp search-replace
Use this file when migrating domains, switching http→https, or changing paths.
Recommended workflow
- Backup:
wp db export
- Dry run:
wp search-replace OLD NEW --dry-run
- Run for real (carefully choose scope):
- consider
--all-tables-with-prefixif you need to include non-core tables with the WP prefix
- consider
- Flush:
wp cache flushwp rewrite flush
Multisite notes
For multisite, decide whether you’re replacing:
- a single site (
--url=...), or - across the network (
--networkor iteratingwp site list).
Read:
references/multisite.md
Common flags
--dry-run--precise(slower but can be safer in complex cases)--skip-columns=...(avoid touching large/binary columns)--report-changed-only
Serialization caution
WP-CLI search-replace is designed to handle PHP serialized data, but you must still:
- avoid replacing within binary/blob columns
- validate results with application smoke tests