• Get In Touch
April 4, 2018

How To Move WordPress From A Sub-Domain to Root Domain

Using Wordpress? Get our lightening fast Wordpress Optimised Hosting.
Get Wordpress Hosting

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.

Using Wordpress? Get our lightening fast Wordpress Optimised Hosting.
Get Wordpress Hosting

Share this Article!

Related Posts

5 Website Hosting Solution Trends for 2022 and Beyond

5 Website Hosting Solution Trends for 2022 and Beyond

Looking for the right web hosting solution for your website can be an intimidating task. Options nowadays are more diversified than ever, and each year brings new developments in the web hosting market. If you have no clue of what to look out for, you can find yourself overwhelmed with the choices. Hence, you must […]

64 Content Marketing Statistics Demonstrating the Power of Content

64 Content Marketing Statistics Demonstrating the Power of Content

Content marketing continues to be one of the most valuable tools for today’s online businesses. With content, you can improve your chances of reaching your target audience, boost your search engine standing, and even unlock new opportunities for sales. The more content you produce, the more you can strengthen your domain authority, demonstrate your thought […]

53 User Experience Stats for 2022

53 User Experience Stats for 2022

User Experience (UX) is one of the most crucial factors to consider in web design. As the number of websites and applications in the world today continues to accelerate, businesses are under more pressure than ever to impress customers straight away. If a user visits your website and finds slow-loading pages, clunky navigation, or errors, […]

How to increase the memory limit in WordPress

How to increase the memory limit in WordPress

Do you need to increase the memory limit in WordPress? Getting an error about memory Exhausted? The memory limit is one of the most common WordPress errors as the default limit of memory in WordPress is only set to 64mb! But there’s good news! The Memory Exhausted error is one of the easiest to fix […]

All in One WordPress Migration Vulnerability

All in One WordPress Migration Vulnerability

A vulnerability has been discovered in the “All In One WordPress Migration” WordPress plugin. All versions earlier than, and including 6.97 contain a vulnerability which allows Cross-Site Scripting (XSS). With over 2 million active installations, this vulnerability has the potential to be high impact, however, this is lessened by the nature of the vulnerability, which […]