I found a great article over here that had this information on how to Transfer / Move a WordPress Blog from one Domain to another. Thanks Kavoir for that solid article! It helped a lot.
Assume you won’t change the details of the WordPress database connection, then there’d be no need to change or modify any PHP files at all. Just the database tables and related values concerning the URLs.
The idea is to find all table field values containing the string ‘olddomain.com‘ which is your old domain and change it to the new domain ‘newdomain.com‘. Follow me:
- Copy all the WordPress PHP program files from the old directory to the new one which the new domain is pointed at.
- Connect to WordPress database by phpMyAdmin or plain mysql command or whatever you are familiar with. But this example will only go with phpMyAdmin.
- In phpMyAdmin, at the database level, click ‘Search‘ -> ‘Select All‘ -> Search for ‘olddomain.com‘ -> Click ‘Go‘. In most cases, there are just 2 tables that need to be modified accordingly: wp_posts and wp_options.
- Click ‘Browse’ to look for records with the string ‘olddomain.com‘ in them.
- For ‘wp_options’, edit each record and find all occurrences of the old string ‘olddomain.com‘ and modify it to ‘newdomain.com‘. Click ‘Go‘ to update.
- For ‘wp_posts’, you can leave the guid field intact or update it with the new domain string but it doesn’t matter much. The hard part is to update the post content of all posts and replace all occurrences of the old domain string to the new one. You can get all this done by the following SQL query:
UPDATE wp_posts SET post_content = REPLACE(post_content, 'olddomain.com', 'newdomain.com')
Now you should be set, fire up your browser and navigate to your blog at the new domain and check everything out to see if it’s working properly.
Leave a Reply