{"id":1970,"date":"2026-06-19T15:51:36","date_gmt":"2026-06-19T07:51:36","guid":{"rendered":"https:\/\/blog.ttwow.top\/?p=1970"},"modified":"2026-06-19T21:27:27","modified_gmt":"2026-06-19T13:27:27","slug":"wordpress%e4%bf%ae%e6%94%b9%e5%9b%be%e7%89%87%e5%9f%9f%e5%90%8d","status":"publish","type":"post","link":"https:\/\/blog.ttwow.top\/?p=1970","title":{"rendered":"wordpress\u4fee\u6539\u56fe\u7247\u57df\u540d"},"content":{"rendered":"<p>\u4f60\u8981\u7684\u662f<strong>\u53ea\u6539\u9644\u4ef6\uff08uploads\uff09\u8d44\u6e90\u57df\u540d<\/strong>\u7684 SQL\uff0c\u5bf9\u5427\u3002<\/p>\n<p>\u8fd9\u91cc\u7ed9\u4f60\u4e00\u5957\u201c\u6700\u5b89\u5168\u3001\u6700\u7cbe\u51c6\u201d\u7684\u7248\u672c\u3002<\/p>\n<hr \/>\n<h1>1. \u53ea\u6539\u6587\u7ae0\u91cc\u7684\u56fe\u7247\uff08post_content\uff09<\/h1>\n<pre><code class=\"language-sql\">UPDATE wp_posts\nSET post_content = REPLACE(\n    post_content,\n    &#039;http:\/\/old.com\/wp-content\/uploads\/&#039;,\n    &#039;http:\/\/new.com\/wp-content\/uploads\/&#039;\n);<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u662f HTTPS\uff1a<\/p>\n<pre><code class=\"language-sql\">UPDATE wp_posts\nSET post_content = REPLACE(\n    post_content,\n    &#039;https:\/\/old.com\/wp-content\/uploads\/&#039;,\n    &#039;https:\/\/new.com\/wp-content\/uploads\/&#039;\n);<\/code><\/pre>\n<hr \/>\n<h1>2. \u4fee\u6539\u9644\u4ef6 GUID\uff08\u5efa\u8bae\u53ea\u6539 uploads\uff09<\/h1>\n<pre><code class=\"language-sql\">UPDATE wp_posts\nSET guid = REPLACE(\n    guid,\n    &#039;http:\/\/old.com\/wp-content\/uploads\/&#039;,\n    &#039;http:\/\/new.com\/wp-content\/uploads\/&#039;\n)\nWHERE post_type = &#039;attachment&#039;;<\/code><\/pre>\n<hr \/>\n<h1>3. \u5982\u679c\u4f60\u60f3\u66f4\u7a33\uff08\u63a8\u8350\u8fd9\u4e2a\uff09<\/h1>\n<p>\u907f\u514d\u8bef\u4f24\u5176\u4ed6 URL\uff0c\u53ea\u6539 uploads\uff1a<\/p>\n<pre><code class=\"language-sql\">UPDATE wp_posts\nSET guid = REPLACE(\n    guid,\n    &#039;old.com\/wp-content\/uploads\/&#039;,\n    &#039;new.com\/wp-content\/uploads\/&#039;\n)\nWHERE post_type = &#039;attachment&#039;;<\/code><\/pre>\n<hr \/>\n<h1>4. \u5982\u679c\u8fd8\u6709\u201c\u7f29\u7565\u56fe \/ \u63d2\u4ef6\u5b58\u50a8\u8def\u5f84\u201d<\/h1>\n<p>\uff08\u53ef\u9009\uff0c\u4f46\u5f88\u591a\u7ad9\u9700\u8981\uff09<\/p>\n<pre><code class=\"language-sql\">UPDATE wp_postmeta\nSET meta_value = REPLACE(\n    meta_value,\n    &#039;old.com\/wp-content\/uploads\/&#039;,\n    &#039;new.com\/wp-content\/uploads\/&#039;\n);<\/code><\/pre>\n<hr \/>\n<h1>5. \u6700\u63a8\u8350\u6267\u884c\u987a\u5e8f\uff08\u91cd\u8981\uff09<\/h1>\n<pre><code class=\"language-text\">\u2460 wp_posts.post_content\n\u2461 wp_posts.guid (\u53ea attachment)\n\u2462 wp_postmeta\uff08\u5982\u679c\u786e\u8ba4\u6709\u65e7\u57df\u540d\uff09<\/code><\/pre>\n<hr \/>\n<h1>6. \u4f60\u8fd9\u79cd\u8fc1\u79fb\u573a\u666f\u7684\u5173\u952e\u70b9<\/h1>\n<p>\u4f60\u73b0\u5728\u7684\u60c5\u51b5\u5176\u5b9e\u662f\uff1a<\/p>\n<pre><code class=\"language-text\">\u56fe\u7247\u6587\u4ef6\u5df2\u7ecf\u5728\u670d\u52a1\u5668\n\u53ea\u662f\u6570\u636e\u5e93\u57df\u540d\u6ca1\u7edf\u4e00<\/code><\/pre>\n<p>\u6240\u4ee5<strong>\u4e0d\u9700\u8981\u52a8 uploads \u6587\u4ef6\u5939<\/strong>\uff0c\u53ea\u4fee\u6570\u636e\u5e93\u5373\u53ef\u3002<\/p>\n<hr \/>\n<h1>7. \u4e00\u53e5\u8bdd\u603b\u7ed3<\/h1>\n<p>\u53ea\u505a\u8fd9\u4e24\u4e2a\u6838\u5fc3 SQL \u5c31\u591f\u4e86\uff1a<\/p>\n<pre><code class=\"language-sql\">UPDATE wp_posts\nSET post_content = REPLACE(post_content,&#039;old.com\/wp-content\/uploads\/&#039;,&#039;new.com\/wp-content\/uploads\/&#039;);\n\nUPDATE wp_posts\nSET guid = REPLACE(guid,&#039;old.com\/wp-content\/uploads\/&#039;,&#039;new.com\/wp-content\/uploads\/&#039;)\nWHERE post_type=&#039;attachment&#039;;<\/code><\/pre>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u8981\u7684\u662f\u53ea\u6539\u9644\u4ef6\uff08uploads\uff09\u8d44\u6e90\u57df\u540d\u7684 SQL\uff0c\u5bf9\u5427\u3002 \u8fd9\u91cc\u7ed9\u4f60\u4e00\u5957\u201c\u6700\u5b89\u5168\u3001\u6700\u7cbe\u51c6\u201d\u7684\u7248\u672c\u3002 1. \u53ea [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[135],"tags":[79],"class_list":["post-1970","post","type-post","status-publish","format-standard","hentry","category-code-snippets","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1970"}],"version-history":[{"count":2,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1970\/revisions"}],"predecessor-version":[{"id":1976,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1970\/revisions\/1976"}],"wp:attachment":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}