How to move all posts & attachments from one wordpress blog to another

February 4th, 2010 § 0

Sometimes, albeit rarely, I will need to move all my posts from one WordPress blog to another one.  This is a daunting task, but it does not need to be.

WordPress and .htaccess actually make this very easy!  In three easy steps, you can have all of your WordPress content moved from your original blog location to your new one.

Side Note: This blog post assumes you have set up your new website and installed WordPress (2.9.1 or better) there already.  If you need to, upgrade your WordPress installation before going on.

1. Export all of your blog posts

With WordPress you have access to a tool for exporting all of your content into an XML file format.  Do not worry about what XML is, or why it exports to this format. What you need to know here is how to export and where the file saves, let the rest be taken care of by WordPress.

To get to the export tool go to the left sidebar and click the downward arrow next to tools like so:

Click the arrow here

The menu will look like this when it expands:

Expanded Tools Menu

Now click the “Export” link, and you will see the following:

The Export Page

You can choose which author you want to export, but for our purposes we are moving ALL the content, so we chose to leave it on “All Authors”.  When you hit the download button, you will be prompted to open or save the file. Just save the file in a location on your computer where you can find it easily.

2. Import all of your blog posts

Once you have an export file saved to your computer, you are ready to go back to the same Tools Menu from above, but on your new blog site. Click on “Import”.  Here, you will see a page that looks like this:

Since we are going to import from a WordPress blog, click the blue “WordPress” link at the bottom to see this page:

Just like a normal upload form, click the browse button to choose the file you downloaded in the preview step. Then click “Upload and Import”, which will allow your new website to pick up the posts you exported.

You may get an option on the next page, which will say “Import and Download all attachments”, DO THIS. It will allow WordPress to download the attachments in each of your original posts from your old server and put them on your new server. This will let you keep the great content you worked so hard to create the first time.

The last option you get is what user to import all the posts as. Go ahead and choose the username you want all of your posts to show up under.

Once you see all the posts are on your new site, you are ready to make sure that ALL traffic from your old domain go to your new one.

3. Setup .htaccess on the old blog to redirect all your traffic

The .htaccess file is a little file that works in the background on your server.  It is typically used to tell the server some special action to perform whenever a page is requested.  In this case, we are going to tell it to redirect ANY traffic from the old domain to the new domain and make sure the URLs are similar. This is important because if someone goes to your post about how delicious spam is on the old server, you want them to go to the same post on the new server.

You can actually just download an example .htaccess file with the link below. You will need to edit the part that says “old domain” and the part that says “new domain” to be your old and new domains, respectively.  The rest of the code in the file is exactly the same as what WordPress has you put in by default.

Example .htaccess file

You will actually edit the .htaccess file that comes with WordPress to have this extra content (this is in the example download above):

  1. Options +FollowSymLinks
  2. RewriteEngine on
  3. RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
  4. RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]

DO NOT WORRY about the other code, just find this block and change the URLs appropriately.

The final code will look like this:

  1. # BEGIN WordPress
  2. <IfModule mod_rewrite.c>
  3. RewriteEngine On
  4. RewriteBase /
  5.  
  6. Options +FollowSymLinks
  7. RewriteEngine on
  8. RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
  9. RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
  10.  
  11. RewriteCond %{REQUEST_FILENAME} ^wp-content.*
  12. RewriteCond %{REQUEST_FILENAME} ^wp-admin.*
  13. RewriteCond %{REQUEST_FILENAME} ^wp-include.*
  14. RewriteCond %{REQUEST_FILENAME} !-f
  15. RewriteCond %{REQUEST_FILENAME} !-d
  16. RewriteRule . /index.php [L]
  17. </IfModule>
  18. # END WordPress
  19.  
  20. Options -Indexes

Once you have the file edited with your new URL, just upload it to your OLD server so that it replaces the old .htaccess file.

Now, try to go to the old website with any blog post link (search Google for pages from your site),  and see what happens to the URL when you go there. You should see the URL change to the new server’s domain with the same post path as you selected.

You are now set up and ready to go on your new server.

Tags: , , , , , , , , , , , , ,

Sphere: Related Content

Tagged: , , , , , , , , , , , , ,

§ Leave a Reply

What's this?

You are currently reading How to move all posts & attachments from one wordpress blog to another at Reinforce Media, LLC.

meta

FireStats icon Powered by FireStats