WordPress is usually migrated for one of two reasons: the old host got slow or expensive, or the brand name and domain changed. In both cases the main fear is the same: the site going down for days or losing rankings that took years to build.

Both can be prevented, as long as the steps happen in the right order and the domain's nameservers are the last thing you change.

How many stages does a WordPress migration have?#

Five: a full backup, moving files and database, hidden testing on the new host, changing nameservers and, if the domain changed, a permanent redirect.

Five stages of a WordPress migration: full backup, move, test, change nameservers and redirect

Most failures come from changing nameservers before testing. Then visitors see a half-working site and you have to find the problem under pressure.

What should you do before migrating?#

Take a full backup stored outside both hosts, and list the things configured outside WordPress.

  • Full backup: all site files and a database export. The automatic method is in automatic database backups on cPanel.
  • Mailboxes: if your domain's email is on the same host, it must be created on the new host too; otherwise emails get lost after the nameserver change.
  • Cron jobs: write down the commands in cPanel's Cron Jobs section.
  • PHP version and limits: set the new host's PHP version equal to or newer than the old host's.
  • TTL: TTL is how long other servers keep your domain's information in memory. If you manage the domain's records yourself, lower it a day or two before the migration so the change spreads faster.

How do you move files and the database?#

There are three ways: the new host's free migration service, a manual move in cPanel or a migration plugin. If the new host does the migration itself, that is the easiest route; just verify the result in the testing stage.

For a manual migration:

  1. In the old host's File Manager, compress the contents of public_html into a zip file with the Compress option and download it.
  2. In the old host's phpMyAdmin, select the database and export an SQL file from the Export tab.
  3. On the new host, create a database and a user and connect the user to the database, the same way as in installing WordPress on cPanel hosting.
  4. Upload the zip file into the new host's public_html and Extract it.
  5. In the new host's phpMyAdmin, import the SQL file from the Import tab. If the database is larger than the upload limit, ask your host's support to import it.
  6. In wp-config.php, enter the new database details.
PHP
define( 'DB_NAME', 'newuser_wpdb' );
define( 'DB_USER', 'newuser_wpuser' );
define( 'DB_PASSWORD', 'CHANGE_ME' );
define( 'DB_HOST', 'localhost' );

Do not touch the $table_prefix value in the same file. It must match exactly the prefix of the tables you imported, or WordPress shows a fresh install page.

How do you test the site before changing nameservers?#

With the hosts file on your own computer, which sends the domain to the new server for you only. The hosts file is a file in your operating system that is read before asking domain name servers.

  1. Find the new host's IP address in that host's cPanel.
  2. On Windows, open C:\Windows\System32\drivers\etc\hosts in a text editor with administrator rights (on macOS and Linux it is /etc/hosts).
  3. Add a line like 203.0.113.10 example.com www.example.com; replace the IP and domain with real values.
  4. Close the browser completely and open the site. Now only you see the new host's version.
  5. Try the home page, several posts, dashboard login, the contact form and, if you have a shop, the cart.
  6. After testing, delete that line.

At this stage the browser may warn about the certificate, because the new host's free certificate is not issued until the domain points to it. This is normal. If you see a white screen or a database error, fixing common WordPress errors can help.

What else do you need if the domain changes?#

Three extra jobs: replacing the address in the database, a 301 redirect from the old domain and announcing the change in Search Console.

Replacing the address. Serialized data is a format PHP uses to turn arrays into text, and it records the length of each string. For this reason, do not change the address with a direct SQL REPLACE command; use a plugin that supports serialized-data-aware replacement. If your host gives you terminal access and WP-CLI (optional), this command does the same job; first use --dry-run to see what would change:

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

Permanent redirect. Keep the old domain on a host and put this rule in its .htaccess so every old URL goes to the same page on the new domain:

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

Search Console. Add and verify the new domain in Search Console, use the Change of Address tool on the old domain's property and submit the new sitemap. For the remaining address and canonical details, see WordPress technical SEO.

What should you check after the migration?#

Six items that live outside WordPress content and are usually forgotten: permalinks, certificate, email, cron, cache and external services.

ItemWhat to check
PermalinksClick Save once in the Permalinks settings
SSL certificateAfter the nameserver change, check that it was issued in SSL/TLS Status
EmailTest a contact form and a password reset email
Cron jobsRecreate the commands on the new host
CacheClear the plugin cache and the host cache
External servicesTest your payment gateway or AI service connection from the new server

Do not underestimate the last one. If the site has a chatbot or an AI plugin, the new server may not be able to reach that service; tips are in a support chatbot for your WordPress site.

Where is WordPress migration heading?#

The general direction is clear: hosts have made free migration, one-click copies and staging a normal part of the service, and tools for announcing a domain change to search engines are well established. The main complexity is no longer technical; it is doing things in order and not forgetting what lives outside WordPress.

To be ready:

  • Do not hardcode the domain in theme or personal plugin code; use WordPress functions to build addresses.
  • Keep a list of settings outside WordPress, such as email, cron jobs and domain records.
  • Every few months, test restoring a backup on a subdomain; it is the same as a migration drill.

Summary#

  • The order: backup, move, hidden test, change nameservers, redirect.
  • The table prefix in wp-config.php must match the imported database.
  • Test the site with the hosts file before visitors see it.
  • On a domain change, replace addresses with a serialized-data-aware tool.
  • Keep the old domain's 301 redirect for at least a year.