Move WordPress Blog to New Domain/Location or in another folder/directory

You usually need to move your blog (WordPress) if you are switching your web host as we generally work on localhost.You must also need to ‘move’ your website if you are transferring it to a new domain, new folder, or creating an alternate version on a local server.

After uploading file and updating wp-config.php.We have found that there are lots of URL in the database, It is very hard to update these rows one by one with new URL.
Don’t worry. It is very simple to go

Just 4 steps to do.

1. Query to Update WordPress Settings

UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-web-url.com’, ‘http://www.new-web-url.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

2. Query to Update Permalinks

UPDATE wp_posts SET guid = replace (guid, ‘http://www.old-web-url.com’,’http://www.new-web-url.com’);

3. Query to Update Any Links Embedded In Content

UPDATE wp_posts SET post_content = replace (post_content, ‘http://www.old-web-url.com’, ‘http://www.new-web-url.com’);

4. Query to Post Metas

UPDATE wp_postmeta SET meta_value = replace (meta_value,’http://www.old-web-url.com’,’http://www.new-web-url.com’);

Sometimes, you have omitted the www from your domain when cross-linking posts or referencing images, so you should also run these above query without the ‘www’ for your old URL.

After following these steps, hope you will found your blog or website fully functional.
If it is still not functional, make a comment below this article with explanation what issue you are facing.

9 thoughts on “Move WordPress Blog to New Domain/Location or in another folder/directory”

  1. When you are editing an article in WordPress, there will be many revision copies being saved automatically. This is a waste of resources because excessive revision records can increase the burden of the database.You can delete all revision by below simple query.

    DELETE a,b,c FROM wp_posts a
    LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
    LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
    WHERE a.post_type = ‘revision’

  2. Installing or removing plugins is a very common task for WordPress 🙂 Some of the plugins make use of the post meta to store data pertaining to the plugin. After you have removed the plugin, those data are still left inside the post_meta table, which will no longer be needed.You can clean up the unused post meta value by below query.

    DELETE FROM wp_postmeta WHERE meta_key = ‘your-meta-key’;

  3. Thanks Amisha for sharing such a good experience with wordpress.

    Popular articles/posts receive plenty of pingback.When this happens, the size of your database increases. You can try removing all the pingback by

    DELETE FROM wp_comments WHERE comment_type = ‘pingback’;

  4. Want to delete all Spam Comments.
    You can go by

    DELETE FROM wp_comments WHERE comment_approved = ‘spam’;

    0 = Comment Awaiting Moderation
    1 = Approved Comment
    spam = Comment marked as Spam

  5. Identify the Unused Tags

    In a WordPress DB, if you run query to delete old posts manually from MySQL, the old tags will remain and appear in your tag cloud/listing. This query allows you to identify the unused tags.

    SELECT * From wp_terms wt INNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id WHERE wtt.taxonomy=’post_tag’ AND wtt.count=0;

Comments are closed.