How to Move WordPress up to the Root

by Martin Malden

WordPress Logo. I moved this site from the /blog folder to the root folder recently.

The main reason was to tidy up this domain and, in the process, improve its focus.

That, I hope, will improve the effectiveness of its SEO.

I’ve had this domain for 5 years and during that time I’ve had different folders and pages on it for different products and businesses, so it had all become a bit messy.

Furthermore, this blog, which gets the most traffic on the domain and on which I do the most work, was in a sub-folder.

So moving it up to the root was a bit of a no-brainer.

It’s not a complicated process, but it does require attention to detail, because there’s quite a bit that can go wrong if you’re not careful.

In this example I’ve assumed WordPress was running in the /blog folder on my domain (which it was), but if your WordPress is running in a different folder just substitute that name for /blog.

So here’s what I did:

Before you start

Before you dive in it pays to take some time to research the process and write out a step-by-step plan of the things you need to do.

Every site is different and the process you follow needs to be specific to your site.

So the first thing I did was to set up a test bed by creating a /blog folder on one of my old domains and installing WordPress.

Next I installed and activated plugins that I was using on this site and that rely on or use URLs to do their thing (since the URL of the blog was going to be changing).

This would enable me to check how the move would affect them.

You should also import some posts from an existing blog so you can see whether internal links are affected.

Once everything was set up I then followed the WordPress codex instructions (moving WordPress within your site) and moved the blog to the root folder.

I’ll go through the steps in detail later.

The point of this dry run is to learn what actually happens on your own configuration and prepare the extra steps you will need that aren’t covered in the codex (and quite a few aren’t).

There are a couple of things I discovered immediately as a result of this process:

  1. The step of updating your Permalinks redirects posts and pages but not archive URLs – category and tag pages, for example. You need to update the .htaccess file with a 301 redirect to ensure all pages are re-directed.
  2. After moving the WordPress files you’re met with a white screen when you try to go to the Permalinks step in the WordPress codex, and you need to log in again through the new URL. White screens can be alarming – but this one’s no biggie.

Next, and after you’ve gathered all the information, set out a simple step-by-step plan of the things you need to do. Have it printed out beside you and just work your way through.

The process I’ve set out below will be a good starting point.

But all blogs have their own unique characteristics (different plugins, widgets and layouts), so you’ll need to review it carefully to make sure all the steps you need to take for your blog are covered.

Moving your blog to the root folder

Here then, based on the WordPress codex but augmented with what they left out, is the process:

Step 1:

Copy a range of URLs from your existing blog and paste them into a text file. Copy a URL of each type – e.g. a post URL, a page URL, a category page URL, a tag page URL, an archive URL and so on.

Make sure you have a URL of each type.

You’ll need these later in order to test the redirects once you’ve completed the move, so save them somewhere on your machine.

Step 2:

Back up your entire site – database and files.

Step 3:

Check whether you have a .htaccess file in both your /blog folder and root folder.

If you do, make and save copies of both and then combine them by copying the content of each into a new (third) file. Create this file with a text editor.

Save all three files somewhere on your local machine, so you have backups of everything – you’ll need the content of the combined .htaccess file later.

Step 4:

Clear out any files you won’t need in your root folder after you’ve transferred WordPress.

Be sure to clear out index.php or index.html if they exist. You can leave folders (if you’re still using them) and .html or .php files if they have distinct filenames and you still need them.

Step 5:

Log in to your blog

Step 6:

Go to your Settings > General screen and change the URI to the new address in both the WordPress address and Blog address boxes. The address should be the same in both.

Be sure to do this before moving the WordPress files.

Settings General Screen.

Make sure the new address is the same in both boxes

Step 7:

Click ‘Save Changes’

Do not try to view your blog now!

Step 8:

Fire up your FTP client.

Step 9:

If you’re still on WordPress 2.X delete the /wp-content/cache folder. Skip this step if you’re on WordPress 3.X

Step 10:

With your FTP client, move the content of your /blog folder (i.e. all files and folders within it) to the root directory.

Do not move the /blog folder itself.

Step 11:

Check your /blog folder and delete any remaining files it contains.

Be sure to leave the empty /blog folder in place.

Step 12:

Return to your WordPress admin area and go to the Settings > Permalinks screen.

At this point you’ll get a white screen.

The address bar in your browser will have the new blog address followed by /wp-login.php and some trailing characters.

Remove the trailing characters to leave your login address and hit <enter>

Log in to your blog again and go to the Settings > Permalinks screen.

Step 13:

Check that the Permalink structure is the same as before with only the /blog step removed.

Click ‘Save Changes’

Step 14:

Return to your FTP client and pull up the .htaccess file in your root folder.

Step 15:

Copy the content of the combined .htaccess file you created earlier and paste it into this .htaccess file, being careful not to over-write anything that may already be there.

Paste the combined content immediately under any code that has already been placed there by WordPress.

Step 16:

Add this additional line of code to your new .htaccess file:

redirect 301 /blog/ http://www.yourdomain.com/

Copy that code exactly and replace ‘yourdomain’ with your domain name. If your previous folder was not /blog replace ‘blog’ with your folder’s name.

Be sure to retain the same spacing and all trailing slashes, exactly in the format above.

Step 17:

Save your .htaccess file and, if you’re using Filezilla, click ‘yes’ when it asks if you want to upload the revised file back to the server.

FileZilla Save Changed File confirmation.

Click Yes to upload the saved file back to the server

Step 18:

Go to your plugins screen and check any plugins that rely on URLs to do their stuff.

From my experience you will need to change the ‘Path to backup’ path in WP-DBManager:

WP-DBManager Path to Backup.

Change the path by removing the /blog step

If you’re using a cache plugin you’ll probably need to change various URLs.

With W3-Total-Cache this is handled semi-automatically – it tells you updates (3 of them) are needed and gives you buttons to click.

If you’re using a Sitemap generator plugin you’ll need to check the path to the sitemap.xml file to make sure it’s still valid.

When you’ve done that be sure to re-build your sitemap.

Google Friend Connect will need to be updated – which you’ll have to do through your Google account and then re-paste the code.

Those are the changes I had to make, but I have no idea what plugins you’re using, so be sure to check them all carefully.

Step 19:

Test the re-directs.

Retrieve the file of original URLs you created earlier and paste them individually into your browser’s address bar to make sure all the re-directs work as they should.

As long as you copied the code I gave you in step 16 correctly there should be no problem here.

With my move I had a problem for a while with the re-direct on my home page because I’d deleted the /blog folder. As soon as I replaced it (empty) everything worked perfectly.

Step 20:

Access your Google Webmaster Tools account (if you’re using GWT) and re-submit your sitemap.

Step 21:

If you’re using Google Custom Search access your GCS screens, update the included sites (to remove the /blog) and re-index your sitemap.

That’s it – you’re all done – congratulations..!

What I then did (although it’s not strictly necessary if your redirects are working properly) was to change my blog URL to the new address wherever I could.

That meant my Twitter, Facebook, LinkedIn and other social networking accounts, my email signatures and so on.

Will the move benefit my SEO? I have no idea.

But the domain is certainly a lot more focused and tidy now.

As a footnote, after re-submitting my sitemap in Google Webmaster Tools all my links disappeared and my indexed pages count dropped to 0.

But they were fully re-indexed and my links were all back again after 4 days, and I suffered no noticeable loss of traffic in the interim.

Cheers,

Martin Malden

Please share this article - I'm counting on you!
       
Found this article useful? Get free updates!

Get regular updates, plus a free eBook on how to set up a business online - join us!

Your details are safe with me.
My Privacy Policy.

Previous post:

Next post: