How to Move WordPress to a New Domain

Migrate a WordPress site to a new domain and update every URL so links, images, and logins keep working.

· Updated · 2,166 views

Moving WordPress to a new domain means relocating the files, importing the database, and replacing the old domain wherever it is stored. Skipping the URL update leaves broken links and login loops.

Move the Files and Database

  1. Back up the current site files and database.
  2. Upload the files to the new domain's public_html.
  3. Create a fresh database in cPanel MySQL Databases and import the old database through phpMyAdmin.
  4. Edit wp-config.php with the new database name, user, and password.

Update the URLs

Replacing the domain only in Settings is not enough, because old URLs are stored throughout the database, including inside serialized data. Use a search-and-replace tool that handles serialization, such as the Better Search Replace plugin or WP-CLI:

wp search-replace 'olddomain.co.ke' 'newdomain.co.ke' --skip-columns=guid

If you cannot run a tool, set the core URLs in wp-config.php:

define( 'WP_HOME', 'https://newdomain.co.ke' );
define( 'WP_SITEURL', 'https://newdomain.co.ke' );

Finish Up

  1. Save Settings > Permalinks to rebuild rewrite rules.
  2. Enable AutoSSL on the new domain so it loads over HTTPS.
  3. Add 301 redirects from the old domain if you are keeping it, to preserve search ranking.
  4. Test posts, images, and forms on the new domain.

Clear any caching plugin and your browser cache before deciding whether the migration is complete.

Was this article helpful?

Your feedback helps us improve our documentation.

Still Need Help?

Our support team is available 24/7 to assist you.