How to move a WordPress site from subdomain to root domain

How to move a WordPress site from subdomain to root domainIf you are ready to move your WordPress site from a subdomain to the root domain, we are here to help you.

The whole process is really simple and will take you no more than 10 minutes. After that, you will have a complete working copy of your website on the new location.

There are no special tools required, and if you want, you can complete the whole process without ever installing a single plugin.

Read on and learn how to move a WordPress site from a subdomain to root domain.

Moving a WordPress site from subdomain to root domain

You’re probably familiar with the procedure of moving a WordPress-based site to a new host or a new domain name. The procedure for moving a WordPress-based website from subdomain to root domain is similar, but a lot simpler.

Let’s begin.

 

Step 1. Make a full backup

Before you go any further, make sure that you have a full backup copy of your website. There are some quite useful WordPress backup plugins that you can take advantage of in order to have an up-to-date copy at hand at all times.

Check out our guide on to the best ways to back up WordPress.

When the full backup is ready, store it separately.

Step 2. Move your files

Using the File Manager in your web hosting control panel, navigate to the files you want to move. Select them all, and using the Move (or Copy) functionality, move them to the required destination.

If you don’t have a control panel, you can do the same process with an FTP client. Simply download the required files and folder to your local machine and then upload them to their new destination.

Step 3. Update site settings

When the migration of your WordPress files is finalized, you’ll be locked out from accessing the admin area on the root domain. Each attempt to log into the root domain name will result in an automatic redirection to the admin area of the subdomain.

In order to fix this, visit the root directory of your domain name. After that, edit the wp-config.php file. You have to add these lines before the line ‘That’s all, stop editing! Happy blogging’.

define('WP_HOME','http://site.com');
define('WP_SITEURL','http://site.com');

Of course, ‘site.com’ has to be replaced with the name of your own domain. If you’d like ‘www’ to be used by your root WordPress-based website, add the URLs with ‘www’ before their names.

Now the admin area of the root domain name for your website is accessible.

Step 4. Update your links

Although you’ve just moved your WordPress-based website from the subdomain to the root domain directory, there are still a few things you need to take care of.

For instance, the links inside the WordPress database which are still pointing towards the subdomain.

There’s a plugin for that.

In this case, you can choose from Velvet Blues Update URLs, Go Live Update URLs, or Better Search Replace.

With each of them, you simply have to put in the old URL, the new URL and hit the “Replace” button.

Step 5. Redirect traffic from the subdomain to the root domain

According to search engines, a subdomain is a separate website. That’s why it’s of major importance to redirect them (Google in particular) to your root domain directory the very next moment following a transfer.

This is the only way to keep your website’s SEO rankings.

To do this, head back to File Manager (or your FTP client) and go to your subdomain. In there, look for a .htaccess file. If you can’t find one, simply create a new one. Then copy-paste the following code inside:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain\.site\.com$ [NC]
RewriteRule ^(.*)$ "http://site.com/$1" [R=301,L]

Remember to switch ‘subdomain’ name with your own domain name and ‘example.com’ with your domain name.

The RewriteRule line from the example above uses a non-www URL. If you’d like to use ‘www’ in your root domain name directory, all you have to do is add your URL with a ‘www’ prefix.

 

***

You’re all done! Your WordPress-based website has been moved from the subdomain to the root domain.



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.