Domain.com offers
Constant Contact
StudioPress
HobbyTron
This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies. Find out more.

How to Move WordPress From Subdomain to Root Domain

 Posted by  Add comments
 

Move WordPress: Subdomain to Root Domain

How to Move WordPress From Subdomain to Root Domain

In this tutorial, I will show you how to move WordPress from subdomain to root domain. As a bonus, the method used here to move a WordPress site from subdomain to root domain will also preserve your SEO rankings as well.

This is the most straight forward process to get WordPress out of the subdomain and into the root directory.

 

Video Tutorial

Note: Textual instructions follow the video if that is what you prefer.

 

Moving WordPress: Subdomain to Root Domain

As search engines consider a subdomain to be a totally different website to your main domain, you need to make sure, when performing this modification, that search engines are correctly redirected to the root domain.

Correct redirection will help preserve search rankings after moving your website.

  • A subdomain is a domain that is part of a larger domain, an extension of your root domain name.
  • URL: http://sub.mysite.com/index.html
    Top-level domain name: com
    Second-level domain name: mysite.com
    Domain or host name: mysite.com
    Subdomain: sub.mysite.com
  • With hosting providers such as GoDaddy, you can add up to 100 subdomains per domain name.

 

How to Move WordPress From Subdomain to Root Domain

Moving a website from a subdomain to the root domain is relatively straight forward. Primarily because both are usually hosted with the same web hosting company. The only complication comes when we have to ensure the sites link structure remain valid. We cover this problem later.

For now, let’s take a look at the process of moving a WordPress site from subdomain to root domain.

Step 1: Backup Your Website

Before continuing, create a complete backup of your site. This should include a database backup as well as a copy of all your sites files and folders.

If you have an automated WordPress backup solution installed, force it to make a complete backup now. This is to ensure you have the latest update.

  • When you have created a complete backup, store it in a safe place, such as on your computer. Do not store it on the server.

If you do not have an automated backup installed, there are plenty of WordPress backup plugins you can use to keep your WordPress content safe. Install one now.

Step 2: Clean public_html Directory

Move any old WordPress related site files from the public_html (www or root) directory to a folder called backup. This includes any index.html and index.php files.

  • Do not move server related folders in the public_html directory such as cgi-bin. It’s okay for those to stay in place.

You MUST remove all those old WordPress site files and folders, so they don’t interfere with the new WordPress install. Having an index.html and index.php in the same folder causes confusion, and it’s highly probable that the index.html file will be used instead of WordPress’ index.php file.

 

Step 3: Maintenance Mode

There is a good chance visitors to your site will see a broken site during the process of moving WordPress from subdomain to root domain. In which case, you might like to consider putting your WordPress Site into maintenance mode.

 

How to Move WordPress From Subdomain to Root Domain

 

Many sites use a maintenance mode page to improve their visitors experience. No one likes to visit a broken site.

Step 4: Move WordPress Files from Subdomain to Root Folder

Next, copy ALL the files in the subdomain folder to the root folder. This can be done using the cPanel’s file manager or an FTP client such as FileZilla.

If using an FTP client, this can be done in two ways:

Method 1: In the remote server area of the FTP application window, toggle open the subdirectory containing the WordPress installation you wish to move. Select all the files in this directory and copy them out of this directory and into the public_html folder or whatever directory this directory is within.

Method 2: This will be a two-stage process. First, you will need to copy the subdomain folder and its contents to your computer. Next, copy the contents of the subdomain folder on your computer, back to the public_html (www or root) folder of your root domain.

  • Leaving the original subdomain in place, will enable your site to continue running.
  • Leaving the subdomain of the site intact is a nice option, as it allows you to keep the WordPress site installed in the subdomain as a test zone.

Be patient, depending upon the size of your website, this process could take quite some time.

The files should now be copied to the public_html folder.

Step 5: Change URL Settings

At this stage, trying to login to the root website will simply send you back to the subdomain website’s admin area. We’ll fix that next.

Using the cPanel’s file editor or text editor attached to your FTP client, edit the wp-config.php file in the root directory of your domain.

You will need to change the defines, WP_HOME and WP_SITEURL, to reflect your new site location. Replace mysite.com with your own domain name.

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

If you want your root website to use www then do not forget to enter the URLs with www prefix.

Save your changes.

You can now visit your WordPress site’s admin area on the root domain name.

http://mysite.com/wp-login.php

 

Step 6. URL Update

Although your WordPress site has been moved to the root domain, there will still be links inside the WordPress database pointing to the subdomain.

This is common problem when moving WordPress to a new domain or directory, the permalinks or URLs embedded in the content is not updated with the move. This means that images and other content will not be shown.

We’ll fix that problem next.

Next, download, install and activate the Velvet Blues Update URLs plugin.

This plugin fixes the problems stated above. It updates permalinks, URLs and content links in your website to reflect the move to the new domain or directory.

 

 

Once activated, from the WordPress dashboard, click Tools > Update URLs.

This brings you to start of the Velvet Blues Update URLs setup process.

Enter the subdomain website address in the Old URL field.

http://sub.mysite.com

Enter the main website address in the New URL field.

http://mysite.com

Under ‘Choose which URLs should be updated’, check all options exceptUpdate all GUIDs‘.

  • Make sure you do NOT check, ‘Update all GUIDs‘.

 

 

Double check your entries, especially your spelling, and click the ‘Update URLs Now’ button when you are ready to continue.

The plugin will now update all URLs in your WordPress database. This may take some time. Once finished, you should see a success message.

Step 7. Redirect All Subdomain Traffic to the Root Domain

With the WordPress files moved and all pointers to the subdomain corrected, you need to ensure your subdomain traffic is redirected to the root domain website.

In your subdomain folder, edit or create an .htaccess file. To redirect subdomain traffic to the root domain enter the following code:

 

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

 

Note: You may need to force your FTP client or cPanel File Manager to show hidden files in order to see the .htaccess file.

  • Replace, subdomain, with your subdomain.
  • Replace, domain, with your domain name.
  • Replace, com, with your top level domain.

Note: The RewriteRule shown here uses a non-www URL. If you want to use www in your root domain, you will need to add a www prefix to your code.

Step 8: Clean Cache

If you are using a caching plug in, you will need to delete all cached pages to ensure current content is displayed.

Congratulations. You have successfully moved your site from sub domain, to root domain.

You can now visit your website to see it in action.

Your final task, is to thoroughly test your website to make sure everything is working, as it should.

Move WordPress from Subdomain to Root Domain Final Thoughts

As with all things, there is always more than one way to do a job. With that in mind, you might like to look at the tutorial, How to Migrate WordPress Hosting: Duplicator DIY Guide.

Well, I hope you liked this tutorial and found it helpful. If you have any comment, corrections or items you think should be added to, ‘Move WordPress from Subdomain to Root Domain’, please do not hesitate to let me have them in the comment box below.


KingSolutions.org.uk is hosted on JustHost

 Leave a Reply

(required)

(required)

187 queries in 2.092 seconds (Child).