How to update WordPress URLs after a migration Print

  • 0

After moving a site to a new domain, or from http to https, old addresses remain stored in the database and need replacing.

Option 1: Better Search Replace plugin

  1. Back up your database.
  2. Install and activate Better Search Replace.
  3. Go to Tools › Better Search Replace.
  4. Enter the old URL (e.g. https://old-domain.co.uk) and the new one (https://new-domain.co.uk).
  5. Select all tables and tick Run as dry run. Check the number of changes it reports.
  6. Untick dry run and run it again.

Option 2: WP-CLI over SSH

wp search-replace 'https://old-domain.co.uk' 'https://new-domain.co.uk' --all-tables --dry-run

Remove --dry-run to make the changes.

Don't edit URLs directly in the database with a plain SQL find-and-replace, as this breaks serialised data used by many plugins and themes.

Afterwards, clear any caches and re-save Settings › Permalinks.


Was this answer helpful?

« Back