Move WordPress with Domain Changed Step by Step Tutorial

Overview

This is a tutorial with solutions to common errors (e.g., 404 error on permalinks) for migrating a WordPress website especially when the domain name is changed.

People with similar experience should know, migrating a WordPress website might be troublesome especially when the domain name is also changed (e.g., common 404 error and it turns out to be about permalink). Here is the step by step tutorial based on my own experience of moving the WordPress site into my local server. I try to simply things as much as I can and give my solutions to all the problems I have encountered during my experience.

The steps and possible errors

I will give the direct steps here and explain the problems I have, note the problems probably just depend on different environments and you might or might not have the same problems. Hope it could give you insights on solving your own issues anyways. Here we go:

1) Copy all the WordPress contents under your website root folder into the new server you migrate to. And suppose the old domain name is “oldwp” and the new domain name is “newwp”

2) Use any tools you used to to export the sql script for your old WordPress website into say “oldwp.sql”

3) Create a new database on your new server “newwp”, say the name is “db1″ as well as your new user name or password. You could also keep the old one as long as you keep the database and the wp-config.php file consistent by following these commands:

$mysql -u root -p
$your db password
$create database db1; -- or specify your own name
$CREATE USER 'u1'@'newwp' IDENTIFIED BY 'p1';
$GRANT ALL PRIVILEGES ON db1.* TO 'u1'@'newwp' IDENTIFIED BY 'p1';

4) Edit wp-config.php file and make the following content consist with the database and user information you just created:

define('DB_NAME', 'db1');
define('DB_USER', 'u1');
define('DB_PASSWORD', 'p1');

5) Import the old website db content by following these commands:

$use database db1;
$source yourpath/oldwp.sql

6) Use this tool  Search and Replace for WordPress Databases Script to replace all the old domain name “oldwp” with your new domain name “newwp”

7) Everything should work now if you got lucky, that is, you should expect to use your wordpress now under the new domain “newwp”. However,  commonly, people would see 404 error whenever they click any links in the new website. This would happen if you set the permalink before. Try to directly visit the wp-login.php in your browser and login into the site, go to settings, change the permalink back to default, and then change it back to your customized one. Try to revisit your new site. It should be working correctly now!

Summary

To summarize, here I just gave a tutorial with solutions to common errors (e.g., 404 error on permalinks) for migrating a WordPress website especially when the domain name is changed. You are very welcome to leave any comments and discussion here!

 


(Please specify the source  烟客旅人 sigmainfy — http://www.sigmainfy.com  as well as the original permalink

URL for any reprints,  and please do not use it for commercial purpose)

Written on October 5, 2014