Moving WordPress from a sub-directory to the root


Let’s say your client has a static HTML website and they have hired you to replace it with a fancy new WordPress site. You want to build the new website without affecting their existing website, and once they approve, you will replace the old website with the new one.

1) Install WordPress in a subfolder underneath their existing website. The current website is likely in the rooot at: domain.com. You can (for example) install WordPress under domain.com/newsite/

2) Customize the new WordPress site until everyone is happy. Now it is time to move the WordPress site to be the main website. This is not a hard process once you know the steps. Here is the step-by-step process on how to do it:

 

1) Back up the existing website files. You’ll need to use FTP to do this. You can log in and copy all of the files in their root folder (usually called public_html on the server) down to your computer for safe keeping.

Make sure that you copy everything except for the folder called “/newsite”. Which contains our new Website.

2) Change the WordPress site location in WordPress Admin. Log into your WordPress Admin, and go into Settings->General. Change the WordPress Address and Site Address fields to be the domain name. They probably have the WP directory in the location now – you’ll want to remove that. This will update the WordPress database entries so that WordPress knows of your new location.

WordPress Site URL Location

3) Move the /WP/ directory to the domain root. Now you are ready to move your WordPress files to their new home. You’ll need to use your FTP program again – this time move the entire WP folder (including all sub-folders) up one level to the root of the domain. Most FTP programs have a “move to parent” function that makes this easy. Essentially, you want to move everything that is in the /WP/ folder up one level to the root of the domain. After this is done, you will no longer need the WP folder.

4) Fix up the URLs of any images or document uploads. Any images or files you have uploaded using the WordPress editor will have old URLs that still include the /wp/ folder in their path. These are stored in the WordPress database. Fortunately, there is a nice little WordPress Plugin that makes it easy to update these instantly. Install the Update URLs WordPress Plugin. Once installed, go to Settings->Update URLs in your WordPress Admin. You can enter your old URL and new URL, and this plugin will change everything up for you automatically. After you are done, you can deactivate the plugin – you don’t need it any more.

WordPress Upate URLs Plugin

5) Update Permalinks. If you have custom permalinks enabled in WordPress, you’ll want to go set that up again so that WordPress can update the .htaccess file in the new directory that it lives in. The reason you have to do this again, is that when you do this in WordPress, it updates a special file called .htaccess in the home directory of WordPress. Now you’ve moved WordPress and it has a new home directory, so you need to do this again so that it will update the .htaccess file in the new home directory.

Go to Admin->Settings->Permalinks and update them.

WordPress SEO Friendly Permalinks

That’s it! It seems a little tricky but it is very straightforward. After you’ve done this once or twice you’ll find that you can move sites in your sleep!