Are you thinking of moving a WordPress site sub-domain to a root domain? The process is fairly easy to follow, and there is a way to save your SEO rankings as well. In this article, we will show you how to easily move WordPress from subdomain to root domain with step by step instructions.
Transferring WordPress from A Sub-Domain To A Root Domain
A subdomain is an extension of your root domain name. For example, http://yourwebsite.example.com is a subdomain of example.com. In this case, example.com is the root domain.
Search engines consider sub-domains to be a totally different website. This is why you need to make sure that you properly redirect search engines to the root domain after the transfer. This will help you preserve search rankings after moving your website.
Unlike moving a WordPress site to a new host or a new domain name, moving a site to root domain is a bit easier. This is because the two are usually hosted by the same hosting company.
Step 1: Create A Backup Of Your Site
You should always keep a backup solution installed on your website for automated backups. There are plenty of WordPress backup plugins that you can use to keep your WordPress content safe.
Once you have created a complete backup, make sure that you store it in a remote location or on your computer.
Step 2: Move Your WordPress Files From The Sub-Domain To The Root Folder
First, you need to connect to your website using an FTP client or cPanel’s file manager. Once connected, go to your subfolder location and download all your WordPress files to your computer.
Next, open the public_html folder of your root domain. Depending on how your WordPress hosting environment is set up, this folder could also be named www or after your domain name.
Now, you need to upload all WordPress files you downloaded earlier to the root directory.
Step 3: Change Your WordPress URL And Site URL Settings
Once you move the WordPress files, you will not be able to access the WordPress admin area on the root domain. Trying to login to the root website will send you back to the subdomain website’s admin area.
To fix this, switch to the FTP client and go to the root directory of your domain name. Next, you need to edit the wp-config.php file and add the following lines just before the line ‘That’s all, stop editing! Happy blogging’.
1 2 | define( 'WP_HOME' , 'http://example.com' ); define( 'WP_SITEURL' , 'http://example.com' ); |
Don’t forget to replace example.com with your own domain name. If you want your root website to use www then you will need to enter the URLs with www prefix.
Save your changes and upload the wp-config.php file back to your website.
You can now visit your WordPress site’s admin area on the root domain name.
Step 4: Update Your URLs
Your WordPress site has moved to the root domain, but there will be links inside your WordPress database pointing to the subdomain. Let’s fix that.
You will need to install and activate the Velvet Blues Update URLs plugin. Upon activation, you need to visit Tools » Update URLs page.
On this page, you need to enter your subdomain URL next to the Old URL option and add your root domain to the new URL. Next, under the ‘Choose which URLs should be updated’ area, you need to check all options except ‘All GUIDs’.
Once you are done, click on the ‘Update URLs Now’ button to continue.
The plugin will now update all URLs in your WordPress database. This may take some time. Once finished, you will see a success message.
Step 5: Redirect All Your Sub-Domain Traffic To The Root Domain
Now that you have moved WordPress files, let’s make sure that your subdomain traffic is redirected to the root domain name.
Go to your subdomain folder and make sure that hidden files are forced to be visible. Your FTP client settings have an option to always show hidden files. If you are using cPanel File Manager, then click on the Settings button at the top right corner of the screen. This will bring up the preferences popup. You need to select ‘Show hidden files’ and then click on the save button.
If your subdomain folder already has a .htaccess file, then you can delete it and create a new one. Inside the new .htaccess file, you need to copy and paste the following code:
1 2 3 4 5 6 | <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^yoursubdomain.example.com$ [NC] RewriteRule ^(.*)$ "http://example.com/$1" [R=301,L] </IfModule> |
Don’t forget to replace your sub-domain with your actual sub-domain, and example.com with your domain name.
Save your changes and upload your .htaccess file to the server.
That’s all! You have now successfully moved your site from a sub-domain to root domain. You can visit your website to see it in action and test that everything is working as it should be.