How to Move WordPress up to the Root

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/

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.


Martin Malden

What do you think?

Comments on this entry are closed.

  • Lydia Apr 7, 2011 @ 18:11

    Hello Martin,

    This is a great guide.
    My only regret is that I should have discovered your blog before I made my migration. Would have saved me a lot of time and stressful moments.

    • Martin Apr 7, 2011 @ 20:55

      Hi Lydia,

      Glad it was useful..!



  • Ed Jun 8, 2011 @ 7:00

    hey martin.
    This is pretty interesting.
    Have you / had you considered leaving everything where it was, but then just copying index.php from blog to the root;
    after that you just need to 1) make a one-line edit of the new copy of index.php in the root to reflect the path to the include, and 2) edit the general settings changing JUST the site address.

    i thought i would have to mess with .htaccess but i didn’t.

    I did this on a test blog and i *think* it worked. though i didn’t test as extensively as you did — i.e. posts and pages seemed fine.

    • Martin Jun 8, 2011 @ 9:07

      Hi Ed,

      No – I didn’t consider that route.

      The reason is because I started with the WordPress codex steps for moving the site, which I linked to above.

      However, I found that the codex left a few things out, which was why I a) tested so extensively and b) entitled this article ‘What WordPress doesn’t tell you…’



  • OVEE SEO Jun 27, 2011 @ 18:35

    You have given a nice picture.
    Recommended for WP users

    Thank you

    • Martin Jun 27, 2011 @ 20:26

      You’re welcome – and thank you.



  • Lisa Jun 27, 2011 @ 21:42

    I followed WP Codex instructions, but a theme I am using has not withstood the move. Plug-ins also failed after the move – I resolved that issue.

    I wanted to ask you if the /blog folder should be emptied after the transfer? This seems to be the only thing that is different than what I did. /blog is containing the original wp files and folders. I also did not add the redirect to htaccess or combine root htaccess with /blog htaccess. I’m having fatal errors all over in my theme.

    I have the theme developer and my host on the topic, but wanted to know if /blog should be emptied. Thanks, Lisa

    • Martin Jun 27, 2011 @ 22:09

      Hi Lisa,

      Yes – I did empty my /blog folder. It needs to be there if you’re using .htaccess to do the redirects, but it can be empty.



  • Paula Jan 7, 2012 @ 20:24

    Firstly, thank you very much for making this thorough tutorial.

    I am currently at the dummy-run stage. I have installed WP on a /blog directory on an unimportant site, so I can practice moving it, as you suggest, but at Step 3 you say:

    “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.”

    I don’t have an .htaccess file at all in the root or the /blog directory.

    Do I have to make one for each? Just for one? Or not make one at all?

    thanks a lot

    • Martin Jan 7, 2012 @ 22:27

      If you don’t have any .htaccess files then don’t worry initially.

      However, you will need to set up the redirect that I referred to and you should do that in a .htaccess file. In this case create the 301 redirect as I described above and paste it into a text file which you can save as .htaccess. (Windows will probably add a .txt suffix).

      Upload this file to your root directory and re-name it to remove the .txt suffix if necessary.



  • Paula Jan 7, 2012 @ 23:09

    That’s great, thanks a lot Martin!

    • Martin Jan 8, 2012 @ 7:20

      You’re welcome – glad it was useful 🙂