Migrating a WordPress Install to a New Domain

When you develop a site on a test server, it's tricky to make sure that none of the old links get carried over to the live site. This tutorial also works if you're moving to a new domain. While using a WordPress export is easier, this method catches everything, which can be important if your theme links to specific pages, since WordPress exports don't preserve post ID's

  1. Download the exisitng /wp-content/ directory (all of it ( some plugins (cforms, wp-eCommerce) contain modified or uploaded files)).
  2. Install wordpress on the new domain. Very few of the settings matter, because they're all going to be overwritten. Nonetheless, it's easiest to use fantastico or Simplescripts to set up the database, and create the basic file structure.
  3. Delete the new /wp-content/ folder, and upload the existing /wp-content/ folder. This step may take a long time, so you can do the next few steps while it's uploading.
  4. Export the old database, using PHPMyAdmin:
    Using PHPMyAdmin to Export the MySQL Table
  5. Open the exported *.SQL file, using a code editor (Eclipse/Aptana, Notepad++, or (god forbid) Dreamweaver), and find and replace the old domain name with the new one.
    Find and Replace in Aptana
  6. After step 4 has completely finished (so that all of the plugins and themes exist before WordPress attempts to use them), use PHPMyAdmin on the new host to delete the newly created database tables
    Drop the tables in PHPMyAdmin
  7. ... and import the new ones.
    Import the Modified file using PHPMyAdmin
  8. On the existing install, set the blog address to the new URL. this ensures that any google juice that the development server may have picked up will be transfered to the new domain (this isn't necessary if the development server doesn't face the internet).
    Changing the Blog Address

6 Comments

  1. Posted 10 Apr 2008 at 7:46 |
    Permalink Quote

    Thanks for putting this up. I’m not planning on moving anytime soon, but I’ve bookmarked it. Who knows what the future will bring.

  2. avatar
    hso
    Posted 25 Apr 2008 at 1:42 |
    Permalink Quote

    In some instances, the SQL data will not contain the http prefix, so it’s better to just find and replace without the http://

    Also, it is imperative that the prefix used while creating the database both on your local server/old site and online/new site are the same. WordPress by default uses wp_ as the prefix (in wp-config.php), but if your any reason you changed it, you should use that very prefix on the new install. Adam, correct me if I am off here.

  3. Posted 25 Apr 2008 at 3:21 |
    Permalink Quote

    @HSO -
    interesting, i’ve never seen a setup that didn’t include the http:// prefix. The reason I included the http:// is to make sure that there aren’t www’s left over. if you’re find/replacing without the http://, you should replace
    'dev.site.local/temp
    with
    'example.com

    And yes, it’s very important to make sure you have the same database prefix.

  4. Posted 13 Aug 2008 at 8:08 |
    Permalink Quote

    Awesome guide, just what I’ve been looking for. I’ve found migrations a little tricky in the past, and this will really help me.

  5. Posted 28 Apr 2009 at 6:25 |
    Permalink Quote

    I refer to this post every time I migrate a site — it keeps me from making one little mistake that ends up taking half an hour to fix. Thanks!

  6. avatar
    Will
    Posted 5 May 2009 at 1:40 |
    Permalink Quote

    Adam,

    thanks for the guide. i’m running into a dead end.

    i’m moving from my home test server at http://www.example.com/test to a Dreamhost server at http://www.domain.com/site.

    I’ve followed your steps but when i have uploaded everything and done the db work, i get a redirect at the .com/site and I get a loop when trying to login.

    any suggestions?

One Trackback/Pingback

  1. How to migrate a wordpress blog to your own domain « one cool site: wordpress blogging tips

    [...] How to migrate a wordpress blog to your own domain I was interested to find this illustrated blogging tips tutorial which describes an alternative method for migrating a wordpress blog to a domain. When you develop a site on a test server, it’s tricky to make sure that none of the old links get carried over to the live site. This tutorial also works if you’re moving to a new domain. While using a WordPress export is easier, this method catches everything, which can be important if your theme links to specific pages, since WordPress exports don’t preserve post ID’s … -> Read the whole article. [...]

Post a Comment

Your email is never published nor shared. Comments that do not follow the guidelines may be removed. By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution. Required fields are marked *
↓ Preview