简体   繁体   English

网站迁移后,是否有任何简便的方法来更新wordpress帖子或页面中的媒体或页面链接

[英]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. 我有一个wordpress网站,我刚刚在本地主机中完成了自定义。 Where i set permlinks http://localhost/nwp as my siteurl and home url. 我将永久链接http://localhost/nwp为我的站点URL和主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 . 当我将此网站迁移到实时服务器时,我将网站网址和主网址更改为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. 但我粘贴在页面和帖子中的url仍旧存在,例如http://localhost/nwp/uploads/2014/img.jpg http://localhost/nwp/your-page等。我可以通过解决此问题打开所有页面或帖子,然后用新链接替换页面或帖子中的旧链接。但是,这会花费太多时间。 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 我不知道有什么其他方法可以轻松解决此问题。请帮助我,如果有人知道一种更好的方法可以轻松解决此问题

If you exported your database you can open it with some editor like Notepad++ and just replace the strings. 如果导出数据库,则可以使用诸如Notepad ++之类的编辑器将其打开,只需替换字符串即可。

As @RadGH mentioned it will be wise to use a serialized search and replace script. 正如@RadGH所提到的,使用序列化搜索和替换脚本将是明智的。 Is is safer. 是更安全。 You can find it here: DATABASE SEARCH AND REPLACE SCRIPT IN PHP 您可以在这里找到它: PHP中的数据库搜索和替换脚本

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. 我们需要执行sql UPDATE查询以更新数据库中的所有内容,如下所示。

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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM