WordPress更换域名后,在数据库里替换原有链接的方法

技术流评论4,8051阅读模式

一般来说,从媒体库里插入的链接会自动替换。但某些时候加入的特殊链接没法替换。这时需要操控数据库来替换。

首先了解一下数据库结构:文章源自原紫番博客-https://www.yuanzifan.com/54048.html

主要链接一般都在WP_Posts里面,以下几个字段需要修改:文章源自原紫番博客-https://www.yuanzifan.com/54048.html

文章内容:Post_content文章源自原紫番博客-https://www.yuanzifan.com/54048.html

默认链接结构:guid文章源自原紫番博客-https://www.yuanzifan.com/54048.html

ping内容:pinged文章源自原紫番博客-https://www.yuanzifan.com/54048.html

这里,Post_content里面,用数据库SQL语句更改即可:文章源自原紫番博客-https://www.yuanzifan.com/54048.html

UPDATE wp_posts SET post_content = REPLACE(post_content,'www.原域名.com','www.新域名.com');

guid字段也要这样做一下文章源自原紫番博客-https://www.yuanzifan.com/54048.html

UPDATE guid SET post_content = REPLACE(post_content,'www.原域名.com','www.新域名.com');

当然,也可以在PHPMyadmin里面直接可视化替换:文章源自原紫番博客-https://www.yuanzifan.com/54048.html

文章源自原紫番博客-https://www.yuanzifan.com/54048.html 文章源自原紫番博客-https://www.yuanzifan.com/54048.html

 

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证