How to Move Your WordPress Site to the Root Domain: An Easy Step-by-Step Guide
If you’re planning to transfer your WordPress site from a subdomain to the root domain, you’re in the right place. In this complete guide, we’ll take you through the entire process, ensuring that your SEO rankings remain intact during the move. Let’s get started!
Step 1: Backup Your Website
Before making any changes, it’s crucial to create a backup of your WordPress site. While you may have an automated backup plugin, we recommend performing a thorough backup that includes your database and all WordPress files. Keep this backup in a secure location, such as a remote server or your personal computer.
Step 2: Download and Transfer WordPress Files
Connect to your website using FTP or cPanel’s file manager. Locate the subfolder and download all WordPress files to your computer. Now, go to the public_html folder (or www folder, depending on your hosting setup) of your root domain. Upload the previously downloaded WordPress files to the root directory.
Step 3: Edit the wp-config.php File
To avoid being redirected to the subdomain’s admin area when accessing the root domain, edit the wp-config.php file in the root directory. Add the following lines just before the “That’s all, stop editing! Happy blogging” line:
define('WP_HOME','http://www.yourdomain.com');
define('WP_SITEURL','http://www.yourdomain.com');
Remember to replace “yourdomain.com” with your actual domain name. If you prefer using the “www” prefix, include it in the URLs as well.
Step 4: Update URLs in the Database
Your WordPress database might still contain URLs that refer to the subdomain. To fix this, install and activate the Go Live Update URLs plugin. Once activated, go to “Tools » Go Live” in your WordPress admin panel. Specify the areas where you want to update the URLs, then enter your subdomain URL as the “Old URL” and your root domain as the “New URL.” Finally, click “Update URLs” to start the update process.
Step 5: Redirect Subdomain Traffic
To smoothly redirect visitor traffic from the subdomain to the root domain, navigate to your subdomain folder and make hidden files visible. Enable the option to show hidden files in your FTP client settings or cPanel File Manager preferences. If your subdomain folder already has an .htaccess file, delete it and create a new one. In the new .htaccess file, add the following code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
Make sure to replace “subdomain.yourdomain.com” with your actual subdomain and “yourdomain.com” with your domain name. If you prefer using the “www” prefix, modify the RewriteRule accordingly. Save the changes and upload the .htaccess file to the server.
In Conclusion
Congratulations on successfully moving your WordPress site from a subdomain to the root domain! Take the time to thoroughly test your website and ensure everything is functioning correctly. If you found this guide helpful, be sure to check out our comprehensive WordPress SEO guide for beginners and explore our top recommendations for the best 404 redirect plugins for WordPress.