我假设您的站点网址在 wp_options 表中以 https:// 开头
你需要更换
<img src="https://example.com/image.jpg" alt="image">
到
<img src="//example.com/image.jpg" alt="image"> 所以他们将使用当前页面的任何协议加载该资源。
先备份数据库
然后更新 wp_posts
UPDATE wp_posts
SET post_content = ( Replace (post_content, 'src="http://', 'src="//') )
WHERE Instr(post_content, 'jpeg') > 0
OR Instr(post_content, 'jpg') > 0
OR Instr(post_content, 'gif') > 0
OR Instr(post_content, 'png') > 0;
还有一个用来捕捉单引号的,以防万一:
UPDATE wp_posts
SET post_content = ( Replace (post_content, "src='http://", "src='//") )
WHERE Instr(post_content, 'jpeg') > 0
OR Instr(post_content, 'jpg') > 0
OR Instr(post_content, 'gif') > 0
OR Instr(post_content, 'png') > 0;