Richard Castera

Application Developer/Designer
  • Home
  • About
  • Projects

Migrate WordPress to a new Server or Directory

If you decide to change the URL or link location of your WordPress Blog due to a new domain or moving to a sub-directory, here are some simple steps that should be done to ensure proper migration without breaking links.

To update WordPress options with the new blog location, use the following SQL command:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.olddomain.com', 'http://www.newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com', 'http://www.newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com', 'http://www.newdomain.com');
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Don't forget to Subscribe and Follow!

Be sure to subscribe to the feed and follow me on Twitter for more insights and resources!

8 Responses to “Migrate WordPress to a new Server or Directory”

  1. Comment #1 - Permalink
    Joe Brunno
    06/02/2009

    This worked perfectly! Thank you so much!

  2. Comment #2 - Permalink
    Lydia
    07/18/2009

    Really great !
    These three command lines is all you need to have your database running again.

    In all the WP migration advices I found, no ones talks about the fact that, in posts everywhere URLs have to be changed ! Plus don’t try to change it by hand, it will take forever.
    I also tried to dump the tables, open the scripts and find and replace “old url” by “new url”, but somehow there was always something messing up.

    So thanks for these simple 3 sql commands that go a long way…

    Lydia

  3. Comment #3 - Permalink
    Richard
    07/19/2009

    @Lydia, Your welcome! I’m happy it helped you!

  4. Comment #4 - Permalink
    Andy
    10/20/2009

    sorry, but where do i have to put these commands?

    thanks for your help

  5. Comment #5 - Permalink
    Richard
    10/20/2009

    @Andy, in your favorite Database Administration tool such as phpMyAdmin.

  6. Comment #6 - Permalink
    Trevor
    11/05/2009

    I tried migrating my blog to a new server by copying all directories and the database over. I got the blog running but when I click on an article it give a 404 error. The domain is exactly the same. I just flipped DNS. Are there any database queries that need to be run to make something happen that I’m unaware of?

  7. Comment #7 - Permalink
    Richard
    12/06/2009

    Hey Trevor,

    Nope this works for me.

    Make sure that any other plugins you have installed don’t have a reference to the old URL. Search the whole database.
    Clear your Cache

  8. Comment #8 - Permalink
    Onno marsman
    03/05/2010

    If you are interested in this post, you might also want to take a look at the ezMigrate plugin for WordPress:
    http://techblog.triptic.nl/ezmigrate-plugin-for-wordpress/

It's Your turn

Click here to cancel reply.
You

CAPTCHA Image
CAPTCHA Audio
Refresh Image



About The Author

Richard is a Web Developer currently working for SankyNet. He is available for freelance work. Visit Shifting Ideas for inquiries. Thanks!
  • Premium Email Templates

    Social Profiles

  • Twitter
  • Facebook
  • LinkedIn
  • Digg
  • Google
  • GitHub

    Last Tweet

  • Beware the heat-seeking Nerf machine-gun coming to a cubicle near you http://om.ly/svHF #fb
  • Follow me
  • Archives

    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • September 2008
    • August 2008
    • July 2008
    • June 2008
  • Categories

    • AJAX
    • Apache
    • Books
    • Drupal
    • Ecommerce
    • Flash
    • Google
    • Javascript
    • jQuery
    • Magento
    • Marketing
    • Mootools
    • My Thoughts
    • MySQL
    • News
    • Photoshop
    • PHP
    • Prototype
    • SEO
    • Web Resources
    • Wordpress
  • My Favorites

    • 37 Signals
    • Andrew Warner
    • Chris Coyier
    • Chris Shiflett
    • Collis Ta'eed
    • Development Seed
    • Drupal
    • HubSpot
    • James Padolsey
    • Joel On Software
    • John Resig
    • jQuery
    • Kevin Rose
    • Life Hacker
    • Magento
    • Mashable
    • Matt Cutts
    • Matt Ryan
    • MySQL
    • NetTuts
    • Noupe
    • Photoshop Tutorials
    • PHP
    • Smashing Magazine
    • Tech Crunch
    • WoorkUp
    • Wordpress

2010 © Copyright. Richard Castera - All Rights Reserved.

Top