- Archive or backup the content of the subdomainBackup the database from phpmyadmin
- Create a database and import database backup taken (For websites in separate web hosting accounts)Move or upload files to the main domain root
- Edit wp-config.php to match database credentials
- Go-to phpmyadmin of the databaseOpen wp_options table
Replace the values of URL for site_URL and home_URL records to match your new domain name e.g https://newwebsite.com
Some permalinks on your website may not work properly after the migration. To fix broken permalinks, we have to make some changes:
- Log in to the WordPress admin panel of your root domain.
- Go to Settings > Permalinks and click on Save Changes. This updates the .htaccess file that controls the permalinks on your site. Any broken permalinks should now be fixed.
Now, the internal links on your website may still point to the old domain, i.e., your subdomain. The best way to fix internal links so that they point to the correct domain name, i.e., the root domain, is to use the Go Live Update URLs plugin. Here are the steps:
- Install and activate the plugin on your root domain.
- Go to Tools > Go Live from your WordPress admin dashboard.
- On the next screen, enter your old and new URLs in their respective fields. The plugin will update all instances of the old URLs in the checked databases. Uncheck any databases that you don’t want to get updated.
- Click on Update Urls to finish.
If you followed the guide, you have successfully moved your WordPress website from your subdomain to your main domain. This method can also be used to move WordPress websites from your main domain to your subdomain as well can be used to clone your WordPress website to a new domain name.