复制数据库,更改数据库中的链接。
UPDATE wp_options SET option_value = REPLACE(option_value, 'old_domain', 'new_domain') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = REPLACE (post_content, 'old_domain', 'new_domain');
UPDATE wp_posts SET post_excerpt = REPLACE (post_excerpt, 'old_domain', 'new_domain');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'old_domain','new_domain');
UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'old_domain', 'new_domain');
UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'old_domain','new_domain');
UPDATE wp_posts SET guid = REPLACE (guid, 'old_domain', 'new_domain') WHERE post_type = 'attachment';更改wp-config文件:
define('WP_SITEURL', 'newdomain');
define('WP_HOME', 'newdomain');还需要做些什么?我对localhost进行了测试,但并不是所有的链接都更新了,并且得到了一些小错误。
发布于 2019-06-10 16:30:53
一些插件将链接以序列化的形式保存在数据库中,比如:s:46:\"/var/www/test/wp-content/themes/test/style.css\"如果你做了一个“替换”,那么你可能会遇到不显示某些数据的问题。为了避免任何问题,最好使用插件。检查:
https://stackoverflow.com/questions/56522721
复制相似问题