Ajesh VC
Ajesh VC

Reputation: 635

Is there any easy method to update media or page links inside a wordpress post or page after website migration

I have a wordpress website, that i just completed customisation within my localhost. Where i set permlinks http://localhost/nwp as my siteurl and home url. And in my website i used links inside my pages and posts for referring images,videos and other pages and posts. When i migrate this website into my live server i changed my site url and home url to http://mydomain.com. but the url i pasted inside pages and posts still exists as old like http://localhost/nwp/uploads/2014/img.jpg ,http://localhost/nwp/your-page etc.. I can fix this issue by opening all pages or posts and replacing those old links inside pages or posts with new links .But it take too much time. i didn't know any other method to solve this problem easily.Please help me If any one know a better method to fix this issue easily

Upvotes: 0

Views: 321

Answers (2)

Ajesh VC
Ajesh VC

Reputation: 635

Thank you all for your Answers. But I just found a secure and easy way without any help of additional download script. we need to execute sql UPDATE query to update all contents in database as below.

mysql> UPDATE wp_posts SET guid = replace(guid, 'http://localhost/nwp','http://mydomain.com');

mysql> UPDATE wp_posts SET post_content = replace(post_content, 'http://localhost/nwp', 'http://mydomain.com');

mysql> UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://localhost/nwp','http://mydomain.com');

Upvotes: 1

Jorge Campos
Jorge Campos

Reputation: 23381

If you exported your database you can open it with some editor like Notepad++ and just replace the strings.

As @RadGH mentioned it will be wise to use a serialized search and replace script. Is is safer. You can find it here: DATABASE SEARCH AND REPLACE SCRIPT IN PHP

Upvotes: 1

Related Questions