How to move a WordPress site to a new domain or server?
- Take a full backup (database and
wp-content). - Copy the files to the new server, and import the database there.
- Edit
wp-config.phpwith the new database name, user, password and host. - Replace the old domain with the new one in the database. Use WP-CLI, because it handles serialized data:
- Save Settings > Permalinks again, check the images and links, and set up 301 redirects from the old URLs.
Terminal output
$ wp post create –post_title="Link test" –post_content='<a href="http://example.com/about/">About</a>' –post_status=publish –porcelain
5
$ wp search-replace 'http://example.com' 'https://new-example.com' –dry-run –skip-columns=guid –report-changed-only
Table Column Replacements Type
wp_options option_value 2 PHP
wp_posts post_content 3 SQL
wp_users user_url 1 SQL
Success: 6 replacements to be made.
Remove --dry-run when you are happy with the report. Never use a plain SQL REPLACE on the database, because the values saved with serialize() will break. See WP-CLI and Backup and Update.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |