How to Move WordPress to Another Domain

WordPress stores the site address in the database: in settings, links inside posts, image paths, theme and plugin settings. So after changing the domain it is not enough to point the new domain at the site - the old address must be replaced in the database too.

Do not replace the domain by hand in an exported .sql file in a text editor. Some WordPress settings are stored "serialized", with the string length inside - a manual replace breaks them: widgets, menus and theme settings disappear.

1. Make a backup

Download a copy of the site files and the database (a backup in the panel or a database export in phpMyAdmin) so you can roll back.

2. Connect the new domain

Add the new domain to the site in the control panel (as an alias or a new site with the same folder), wait until it opens, and issue an SSL certificate for it.

3. Change the site address

  1. Log in to WordPress admin: old-domain/wp-admin.
  2. Open Settings - General.
  3. Set "WordPress Address (URL)" and "Site Address (URL)" to the new address, for example https://new-domain.com, and save.
  4. Log in again at the new address: https://new-domain.com/wp-admin.

4. Replace the old domain in the database

With a plugin. Install Better Search Replace. Put https://old-domain.com in "Search for" and https://new-domain.com in "Replace with", select all tables and first run with "Run as dry run" checked - the plugin shows how many replacements it will make. Then uncheck it and run the replace. The plugin handles serialized data correctly. You can remove it afterwards.

With WP-CLI (if your panel has a Shell client): in the site folder run a check, then the replace:

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

5. Check the site

  • Settings - Permalinks - Save Changes to refresh URL rules.
  • Clear the caching plugin cache and your browser cache.
  • Go through the pages: images, menus, forms. If the old address is still somewhere, search again for old-domain.com without https.

6. Redirect the old domain

To keep visitors and search rankings, set up a permanent 301 redirect from the old domain to the new one - in the control panel or in .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]

In Google Search Console, add the new domain and use the Change of Address tool.

Questions and answers
Most likely the new domain does not open the site yet. Put the old address back: in phpMyAdmin, table wp_options, set siteurl and home to the old address, then repeat the steps once the new domain works.
The database replace did not cover all tables. Run Better Search Replace on all tables again or wp search-replace with --all-tables.
Usually not. If it defines WP_HOME or WP_SITEURL, set the new address there.