[wp-hackers] Website transfering

Daniel Bachhuber wordpress at danielbachhuber.com
Fri Aug 26 21:31:25 UTC 2011


Hey Pasquale,

> I would move a website from a folder (initially called "beta") into another
> folder.
> 
> In theory this operation is very simple in post and page contents there are
> a lot of images with the old path and I would avoid manually editing all
> posts and pages replacing the old path with the new one.

Do you have access to PHPMyAdmin? If you're on a Mac, there's a neat equivalent program: http://www.sequelpro.com/

Basically, what you'll want to do is connect directly to your database, and run SQL statements to find and replace the URL references.

Here are a few I commonly use:

UPDATE wp_posts SET post_content = replace(post_content, 'http://domain.com/beta/', 'http://domain.com/anotherfolder/');
UPDATE wp_posts SET guid = replace(guid, 'http://domain.com/beta/', 'http://domain.com/anotherfolder/');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://domain.com/beta/', 'http://domain.com/anotherfolder/');
UPDATE wp_options SET option_value = replace(option_value, 'http://domain.com/beta/', 'http://domain.com/anotherfolder/');

Obviously, you'd want to replace "domain.com" to whatever your domain is, and use the proper table names.

Hope this helps,

Daniel


More information about the wp-hackers mailing list