How to Move a WordPress Blog from One Domain/Host to Another

worpress-migration-thumb1

Over that last couple of days, I have had the “pleasure” of moving a blog from one hosting provider to another (not that difficult of a task) but ALSO changing domains in the process. While I don’t think this post should the definitive set of instructions, it is a combination of information that I read and gathered, in conjunction with my own experience.

I actually did this migration a couple of times, not by choice mind you. But the process of doing this multiple times aided me in coming up with the steps that follow. The steps worked for me and were based on trial & error and research.

worpress migration thumb1 - HighTechDad™

First off – WARNING – this is tricky for some and very easy to screw up. Don’t come crying to me if you mess something up beyond repair. I’m not a PHP or mySQL guy, I just play one on TV (essentially know enough to be dangerous). I will help where I can but I too had to do a lot of research, reading and trial and error before I got it to work.

Just for reference, I moved my blog from http://weblog.techdad.net to https://www.hightechdad.com.

There is a bit of work that you need to do for this so I recommend that you read through this post fully first before you start doing stuff. I have broken the steps out into 6 General sections:

  1. Prep your old site
  2. Prep your new environment
  3. Work on a local copy of your site
  4. Install old files in new environment
  5. “Shut down” old site
  6. Post production work

Pay Attention: When you are executing command line or mySQL commands, be sure to check quote marks. If you cut and paste from this blog post, you may get incorrect characters for the quotes. It is sometimes better to hand type in the single and double quotes.

Lastly, take notes or keep a log of what you do (just in case you have to do it again like I did). Ready? Let’s go!

Prep Your Old Site

On your OLD DOMAIN and server, do the following:

  1. Make a mySQL backup of your current DB (I use plugin called WP-DBManager and really recommend it)
  2. Download a full copy of your current WordPress web directory (this will preserve the active state of plugins should you ever need that as well as the DB backup you just did)
  3. Print out or save a list of your active plugins (trust me, it’s worth it)
  4. Put site in Maintenance mode (I use a plugin called Maintenance Mode which is great for putting your site offline for the public but still allowing you to see and work with it assuming you are logged in)
  5. Once in Maintenance Mode, disable all non-essential plugins (e.g., leave Maintenance Mode plugin on and WP-DBManager on as well)
  6. Do another full download of your site (optional but do it if you made any changes to plugins – updated or deleted for example)
  7. Go to phpmyadmin (or command line mySQL ) and do a full mySQL dump – or you can probably use the SQL dump that WP-DBManager provided.
  8. Be sure you save original files before making modifications (e.g., I created multiple directories, one for the “original” web files and mySQL dumps, and then one directory for later modifications of files and mySQL on my local machine)

Prep your New Environment

On your NEW environment, do these steps:

  1. Create an empty DB (get all of the details for later: server, db, user, password)
  2. Create a web folder for your new WordPress installation
  3. Create a robots.txt on new site with the following line:
    User-agent:*
    Disallow: /

    This will prevent search engine robots from crawling your site while you work on it

Work on a Local Copy of your Site

On your LOCAL computer (e.g., where you downloaded all of your info to), do the following:

  1. Edit wp-config.php with to set your new domain:

    define('WP_SITEURL', 'http://www.NEW-DOMAIN.com');
    define('WP_HOME', 'http://www.NEW-DOMAIN.com');

    I put these almost at the top of the file prior to other “define” calls.
  2. Edit wp-config.php with your new DB settings (server, db, user, password)
  3. Edit the starting lines of your mySQL dump file  to specify the new DB name in your NEW environment. It should be in the first section. Something like:
    /* CREATE DATABASE 'database_name' DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; */

    USE 'database_name';

    Note: I actually commented out the “create database” part since the provider I use (1and1.com in this case), creates the DB for you. I just used the “use” clause.

  4. For 1and1 users: edit the .htaccess file to force the server to use PHP 5.
    AddType x-mapp-php5 .php

    This prevents you from getting the pesky Server 500 errors.

  5. Do a search for the URL as a content string within your WP directory files. Sometimes plugins or themes have hard-coded links (one called cformsII does this where it writes the full path to the location of the js file). Search for your old domain name “http://www.old-domain.com“. Open and review those files and change them, if appropriate, to “http://www.new-domain.com“. Be sure to try variations of this (e.g., without the “www”)
  6. Delete anything in the wp-content/cache (e.g., if you have a caching plugin enabled)
  7. I commented out the cache info on my wp-config.php file to make sure it was off there as well.

Install Old Files in New Environment

On the NEW Server, do the following:

  1. Upload your local modified DB to your new site. Warning, it’s better to use mySQL commandline than phpmyadmin. There are limits to the sizes of files you can upload using phpmyadmin. For 1and1, I used SSH to connect to my server and also uploaded the DB to a distinct directory via FTP and put it in this directory (e.g., I called it “mysql”). Then, via SSH, I changed to that directory and executed the following command:”mysql -h SERVER -u USER -p DB NAME < DUMP FILE.sql“(without the quotes and obviously updating the SERVER, USER, DB NAME and DUMP FILE with your info)
    and then at the password prompt entered the db password. Hit enter and then let it populate the new DB.
  2. While your data is loading, upload your WordPress files (the ones you modified) to your new server
  3. Wait around while it all transfers
  4. Once everything has transferred, go to http://www.new-domain.com/wp-admin and log in (remember, you site will hopefully still think it is in “Maintenance Mode” based on how you left the old site).
  5. Install and Activate the following two plugins:
    Search & Replace
    Velvet Blues Update URLs
  6. Do search & replace with both plugins with old/new domains
  7. Update permalinks within WordPress
  8. Go to phpmyadmin and run 3 queries/updates:
      Update WordPress Settings in DB
      UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
      Update Permalinks in DB
      UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
      Update Any Links within your blogs content
      UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-url.com', 'http://www.new-url.com');
  9. Go back to your printout and activate all of the other plugins
  10. Test, test and test again
  11. Update your sitemap.xml (via plugin or whatever)
  12. Remove the two lines in wp-config.php where you manually defined new domain
  13. Test again
  14. Remove robots.txt file
  15. Note: you might also want to check the path for your uploads directory as well. In some cases, your new host might have a different path. Go to SettingsMiscellaneous and check to see if it says the default “wp-content/uploads”. If you are getting issues or errors with image displays and such, you may have to tweak that setting.

“Shut Down” the Old Site

Back at your OLD site, you need to tell it to send all traffic to the new site and new URL. The best way to do this is via 303 redirects. You want to be sure you have this in place especially if your previous domain was heavily indexed by the search engines.

  1. Set up redirects: either via hosting control panel or directly in .htaccess (this is a great guide to applying Apache 303 redirects)

Be sure that your redirects preserve the full path to your new site. For example, if www.old-domain.com/test_post/ existed, it should redirect to www.new-domain.com/test_post/.

Post Production Work

This part becomes very subjective. It all depends on what you have set up for your old blog. You may have more or less work to do. The items below are only some suggestions and will probably help you get started thinking about what you need to do.

  1. Update any 3rd party items:
    • Google Analytics
    • Discussion plugins
    • Feedburner
    • Social Profiles
    • Ad networks
  2. Get friend to test

Special thanks go out to the authors of these two articles:
How To Move A WordPress Blog or Website
Move your WordPress blog to a new domain in 10 steps!
Without these sites, I really couldn’t have done it.

Other links:
– WordPress official documentation on how to move WordPress.

As I said, this is a complicated process. I hope that I have not missed any steps. Please leave a comment if this WORKED or FAILED as well as add any suggestions or additions to these instructions. I will update this post as appropriate.

Did you find this solution useful? If so: [paypal-donation reference=”Move WordPress”]

HTD says: While moving a blog to a new server or domain seems daunting, if you follow through the steps and line of logic, you can get it done just fine!

- Advertisement -
- Advertisement -
- Advertisement -

25 Responses

  1. Hello, i have installed wordpress ta domain.org, but i need to have domain.com as main domain (domain.org i wolud lik to be parked) of that installation. If ponit name servers (domain.com) to hosting where is wordpress installed would by blog work??

  2. Hello, i have installed wordpress ta domain.org, but i need to have domain.com as main domain (domain.org i wolud lik to be parked) of that installation. If ponit name servers (domain.com) to hosting where is wordpress installed would by blog work??

  3. Hello, i have installed wordpress ta domain.org, but i need to have domain.com as main domain (domain.org i wolud lik to be parked) of that installation. If ponit name servers (domain.com) to hosting where is wordpress installed would by blog work??

  4. You should be able to have two domains or more pointed to your blog. However, you do have to choose what your main domain will be and use that in the configuration.-HTD

  5. You should be able to have two domains or more pointed to your blog. However, you do have to choose what your main domain will be and use that in the configuration.-HTD

  6. You should be able to have two domains or more pointed to your blog. However, you do have to choose what your main domain will be and use that in the configuration.

    -HTD

  7. http://www.anly.info Free hosting is a complete solution with you everything you need to run your own website. Our

    powerful free hosting plan has PHP 5 and MySQL support. You get a free sub-domain, FTP access.

    Add on your own TLD using the domain manager.
    The Automatic Script Installer (Like Fantastico) is included with every free hosting plan. You

    can install many popular scripts such as PHPbb2 & PHPbb3, Wordpress, Zen-Cart, osCommerce, MyBB,

    UseBB, MyLittle Forum, 4images, Coppermine, SMF, Joomla, e107, XOOPS, PHP Wind, CuteNews, Mambo,

    WikiWig and many more! No need to wait for uploading files, Our Automatic Script Installer

    deploys the files in seconds!

    300 MB disk space,Vista Panel,Web mail
    10 GB Monthly transfer,Password protected folders,POP email accounts
    3 MySQL databases,Automatic installer,Park Domains
    6 Add-on domains,FTP account,Php MyAdmin
    6 Sub domains,Browser File,manager Clustered servers

    Link: Sign Up

  8. Moving a domain ain't that hard. I really thought it took more programming skills than that. Thank you for the tutorial. I'll give it a try as soon as I decide where to move my blog. Now I'm really happy I chose Wordpress, it's easy to use and it doesn't make too much problems when it comes to moving the site.

  9. This is really complicated. But very detailed instruction. Thank you so much for sharing this..

  10. Hello, First I know this post is old but still, maybe someone is watching it.

    I'm trying to prepare myself for a future host from host migration, so I want to do the testing locally, so I've done all that is listed here.

    Done the wp-content backup
    Done the DB backup
    Create a New DB
    Create a New user
    Set permissions to new user
    Restore the downloaded DB into the new database
    Installed wordpress
    configure wordpress
    update via commands the new domain and all stuff

    The connection all went just fine, but no one post appear, no information in the blog.

    I know I can do an export/import via wordpress but I want to do it via the SQL DB (hard) way.

    BUT i know I'm doing something difference which I do not know if should be done in this process :

    First I installed wordpress on IIS (just for the sake of learn how to)
    Second I'm using a different version of wordpress from the actual blog. I have wordpress 2.9.2 in the production site and wordpress 3.0 RC1 in the development site.

    As I said before, my problem is that after I did everything as told me by every guide that I could find, I can not see the information even as the site is working.

  11. I always watch for new comments on posts! Yes, it's a bit old (and stale in my brain) but I will try to help.

    Some things to think about, is the domain changing? Did you do a search for that in the DB? Did you check your WP-config.php file to ensure that you have all of the proper settings there? Sometimes you actually need to get into the DB to check the Options table (I can't remember the exact name) and make sure that none of your old domains are there. I'm not sure what changes happen in the data structure between 2.9.2 and 3.0 RC1 but I have played around with a beta version of 3.0 (not the process you described though).

    Without being able to actually do hands on, it's hard to really tell. Sorry.

    Good luck!

  12. Some things to think about, is the domain changing?….Yes from http://www.nehemoth.com to http://localhost

    Did you do a search for that in the DB?
    Of course and change it via a query

    Did you check your WP-config.php file to ensure that you have all of the proper settings there?…..Indeed, a lot of time

    Sometimes you actually need to get into the DB to check the Options table (I can't remember the exact name) and make sure that none of your old domains are there.

    That it the wp_options and I did it

    I'm not sure what changes happen in the data structure between 2.9.2 and 3.0 RC1 but I have played around with a beta version of 3.0 (not the process you described though)..

    lets wait and see.

    Not problem, thank you for answer me

  13. I found my problem, as the time have passed by, I have multiple tables, so my Table_Prefix should be set to the correct table set.

  14. Wordpress is SEO friendly so settings have to come as on domain registrar’s and more over new web hosting space not have bad network.

  15. Great post…. :)
    This is very easy to understand and move my site.
    Thanks for sharing

  16. Great post…. :)
    This is very easy to understand and move my site.
    Thanks for sharing

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Other articles of interest

Global Product Review Disclosure

Disclosure: This is a global disclosure for product review articles on HighTechDad. It does not apply to Automobile reviews and there are other exceptions. Therefore, it may or may not be applicable to this particular article. I may have a material connection because I may have received a sample of a product for consideration in preparing to review the product and write this or other content. I was/am not expected to return the item after my review period. All opinions within this and other articles are my own and are typically not subject to the editorial review from any 3rd party. Also, some of the links in the post above may be “affiliate” or “advertising” links. These may be automatically created or placed by me manually. This means if you click on the link and purchase the item (sometimes but not necessarily the product or service being reviewed), I will receive a small affiliate or advertising commission. More information can be found on my About page.

About HighTechDad

Michael Sheehan (“HighTechDad”) is an avid technologist, writer, journalist, content marketer, blogger, tech influencer, social media pundit, loving husband and father of 3 beautiful girls living in the San Francisco Bay Area. This site covers technology, consumer electronics, Parent Tech, SmartHomes, cloud computing, gadgets, software, hardware, parenting “hacks,” and other tips & tricks.

Recent Articles

Explore Categories

– Advertisement –

Shop Now!

My Favorite Setapp Apps

Affiliates

  • Mount18_July
  • Save 15% Off at Incase

– Advertisement –

– Advertisement –