我看到您想将WordPress网站从开发环境迁移到新服务器或生产服务器。
最近,我将站点移至生产服务器,并且遇到了同样的情况。我需要更新站点URL,因为WordPress将站点URL存储在数据库中。
我发现使用了很好的MySQL查询,可以轻松地直接从Database更改URL。
SET @search := "http://olddomain.com";
SET @replace := "http://newdomain.com";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "siteurl";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "home";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "product_list_url";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "shopping_cart_url";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "checkout_url";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "widget_text";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "headerImageLogo";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "cunjo_plugin_url";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "wpsr_socialbt_data";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "issuem";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "_transient_dgxdonate_t70pbg1htu_1396322372";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "dgx_donate_log";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "headerBackgroundImage";
UPDATE `wp_options` SET `option_value` = REPLACE(option_value, @search, @replace) WHERE option_name = "transact_url";
UPDATE `wp_postmeta` SET `meta_value`=REPLACE(meta_value, @search, @replace);
UPDATE `wp_usermeta` SET `meta_value`=REPLACE(meta_value, @search, @replace);
UPDATE `wp_posts` SET `guid`=REPLACE(guid, @search, @replace);
UPDATE `wp_posts` SET `post_content`=REPLACE(post_content, @search, @replace);
您只需要将站点URL从旧域名替换为新域名,然后使用PHPMYADMIN在MySQL上执行查询即可。
有关更多参考,请阅读本教程。
https://tryvary.com/wordpress-change-url-in-database-using-mysql-query/