Change domain: replace the old domain in the database
wordpress change domain name | move wordpress to new domain | push staging to live wordpress | replace old url in database | wp-cli | search-replace | migration | seoWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
wp db export /var/www/vhosts/example.com/before-domain-change.sql --path=/var/www/vhosts/example.com/httpdocs && wp search-replace '//old.example.com' '//example.com' --all-tables --skip-columns=guid --path=/var/www/vhosts/example.com/httpdocsCreates a database backup and then replaces every occurrence of the old domain with the new one, regardless of protocol. The leading // matches both http and https links and avoids partial matches inside other words. After the change, set up 301 redirects on the old domain so rankings and backlinks are preserved.
Note: The block editor and some page builders store URLs JSON-escaped as \/\/alt.example.com. For those cases, check a second run with escaped slashes using --dry-run.
Also searched as
- wordpress change domain name
- move wordpress to new domain
- push staging to live wordpress
- replace old url in database