Changing domain means updating the URLs stored throughout the database, not just the files.
1. Prepare
Add the new domain to your hosting account (Client Area, then cPanel → Domains → Create A New Domain if it is an addon), point it at our nameservers, and take a full backup.
2. Update the two main URLs
Add these lines temporarily to wp-config.php:
define('WP_HOME','https://newdomain.com');
define('WP_SITEURL','https://newdomain.com');
This gets you back into the dashboard on the new domain.
3. Rewrite the database
- Install Better Search Replace.
- Search for
olddomain.comand replace withnewdomain.comacross all tables. - Run it as a dry run first, then for real.
Then remove the two lines you added to wp-config.php and set the URLs properly under Settings → General.
4. Redirect the old domain
If you still control the old domain, keep it pointing here and add a permanent redirect in its .htaccess so links and search rankings follow you:
RewriteEngine On
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301]
5. Tidy up
Run AutoSSL on the new domain, re-save permalinks, update the property in Google Search Console and submit a change of address, and update the site URL anywhere it is embedded — email signatures, social profiles, payment gateways.