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:
MySQL
1 2 3 4 5 6 7 8 |
SET @oldsite='http://www.olddomain.com'; SET @newsite='http://www.newdomain.com'; UPDATE wp_options SET option_value = REPLACE(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET post_content = REPLACE (post_content, @oldsite, @newsite); UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, @oldsite, @newsite); UPDATE wp_comments SET comment_content = REPLACE (comment_content, @oldsite, @newsite); UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, @oldsite, @newsite); UPDATE wp_posts SET guid = REPLACE (guid, @oldsite, @newsite) WHERE post_type = 'attachment'; |