How to update WordPress URLs after a migration

How to update WordPress URLs after a migration

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.

    • Related Articles

    • How to fix WordPress images not displaying

      1. Check the image file In Media › Library, open the image and visit its File URL. A 404 means the file is missing; upload it again. 2. Check permissions In File Manager, wp-content/uploads and its folders should be 755 and image files 644. 3. Check ...
    • How to force HTTPS on your WordPress site

      Make sure the domain has an SSL certificate (see How to install a free SSL certificate). In WordPress, go to Settings › General. Change both WordPress Address (URL) and Site Address (URL) to start with https:// and save. You'll be logged out; log ...
    • How to install WordPress

      You can install WordPress in a few clicks from cPanel. Option 1: WordPress Toolkit (recommended) In cPanel, open WordPress Management (WP Toolkit) in the Domains section. Click Install. Choose the domain and, if needed, a sub-folder. Leave the folder ...
    • How to enable auto-updates for WordPress plugins

      In WordPress, go to Plugins › Installed Plugins. In the Automatic Updates column, click Enable auto-updates for each plugin. To enable for all at once, tick the checkbox at the top of the list, choose Enable Auto-updates from Bulk actions and click ...
    • How to fix cURL error 60 in WordPress

      cURL error 60: SSL certificate problem means WordPress can't verify the SSL certificate of a site it's connecting to, for example when checking for updates or contacting a payment provider. Fixes Update WordPress from Dashboard › Updates. Each ...