Problems with moving my Wordpress site to another domain/server

我与影子孤独终老i 提交于 2019-12-04 20:13:29

The main thing you need to do is update 2 fields in the database to the correct domain.

It can be done a few different ways.

Method 1:

Add this line to your wp-config.php file, then visit http://yournewdomain.com/wp-admin.php and log in. This will force the update:

define('RELOCATE',true);

After you log in, you should remove that line.

Method 2:

Add these 2 lines to your theme's functions.php file found at wp-content/themes/themename/functions.php

update_option('siteurl','http://example.com/blog');
update_option('home','http://example.com/blog');

After that, you need to update the GUID for each post. In phpMyAdmin or from the mysql command line issue this:

UPDATE wp_posts SET guid = REPLACE (
guid,
'http://exampleoldsiteurl.com',
'http://examplenewsiteurl.com');

replace exampleoldsite and examplenewsite with the respective domains.

All of this info can be found at http://codex.wordpress.org/Changing_The_Site_URL

You can run these sql queries in phpmyadmin to change URLs in the database after the move for site options, post URLs and URLs in post/page content:

UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');

4/22/2014 Edit: this is a much better solution that won't break PHP serialized data: interconnectit.com WordPress Serialized PHP Search Replace Tool

You will probably need to edit some fields in your database and update the settings in the admin area. There is quite a nice guide here

http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_to_a_New_Server

I think the easiest way is probably:

  • Install a new Wordpress blog
  • Go on old blog Admin panel. Here, in Manage > Export select "all" in menu Restrict Author.
  • Click on Download Export File
  • In new blog go on Manage > Import, choose Wordpress item.
  • In the page that will be shown, select the file just exported. Click Upload file and Import
  • It will appear a page. In Assign Authors, assign the author to users that already exist or create new ones.
  • Click on Submit
  • At the end, click on Have fun

Instead of installing Wordpress on new server. Copy old files to new server, import database and change wp-config. I found this helpful How to Transfer a WordPress website to another Host

There is also a tool available for those who are not confident running SQL update scripts, found at:

Search and Replace for WordPress DB

Remember to delete files after performing the desired actions to the DB, because the script exposes DB username/password found in wp-config.php ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!