This guide intended towards database level changes than the other common changes like moving the files etc.. If you wish to know step by step guide on how to move your WordPress blog to a new URL, please check this link.
I know, there are plugins available to change the website’s URL but I am not sure if the plugins cover the tables which I am going to take care of.
So, without wasting much of the time, let’s get the ball rolling..
Note: Please take backup of your current database before making any of the changes.
- Update the site URL in the wp_options table. – This table holds the values which are very important to run the site. (specially values stored in siteurl and home fields)
UPDATE wp_options SET option_value = REPLACE (option_value,'old_url.com','new_url.com');
- Update wp_posts table – This table holds all the post related data.
UPDATE wp_posts SET guid = REPLACE (guid,'old_url.com','new_url.com');
UPDATE wp_posts SET post_content = REPLACE (post_content,'old_url.com','new_url.com');
- Update wp_links table – This table holds all the links (blogroll) related information, you might want to change the links where the URL is pointing back to one of your site pages or you have link image URL belongs to the old URL.
UPDATE wp_links SET link_url = REPLACE (link_url,'old_url.com','new_url.com');
UPDATE wp_links SET link_image = REPLACE (link_image,'old_url.com','new_url.com');
- Update wp_comments table – This table will have all the data posted in the comments. It is highly possible that some of the users might have posted the links to your site pages. And author URLs and email might be pointing to the old site.
UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url,'old_url.com','new_url.com');
UPDATE wp_comments SET comment_author_email = REPLACE (comment_author_email,'old_url.com','new_url.com');
UPDATE wp_comments SET comment_content = REPLACE (comment_content,'old_url.com','new_url.com');
- And, finally last change in the htaccess file of the old site, so that all the requests made to old site gets redirected to the new one
RewriteRule ^(.?)$ http://new_url.com/$1 [R=301,L]
And that’s it.. you should be good to go after following above steps. And yeah, do not forget to replace new_url.com and old_url.com to your respective site addresses.
I hope these tips help you..