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
- Back up the current site files and database.
- Upload the files to the new domain's
public_html. - Create a fresh database in cPanel MySQL Databases and import the old database through phpMyAdmin.
- Edit
wp-config.phpwith 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
- Save Settings > Permalinks to rebuild rewrite rules.
- Enable AutoSSL on the new domain so it loads over HTTPS.
- Add 301 redirects from the old domain if you are keeping it, to preserve search ranking.
- Test posts, images, and forms on the new domain.
Clear any caching plugin and your browser cache before deciding whether the migration is complete.