Moving a WordPress Blog to a New Domain

I’ve had to move many WordPress blogs from one domain to the next. As a result, this process has become fairly repetitious. So I thought I would share my experience. First, some disclaimers.

  1. If you don’t know what your doing, it might make sense to pay someone else to move your blog…
  2. If you’ve never run an SQL query, this tutuorial probably isn’t for you. However, if your still feeling adventurous try it out!
  3. You will need FTP access, phpMyAdmin or some other SQL client access, and you may need root or WHM access if you run a VPS.
  4. If you have hardcoded any urls into your themes you will need to manually change these urls to match the new domain.

Getting started…

Our goal is to move the site to a new domain first. Once we’re sure the site is up and running on the new domain, we can safely redirect the old domain to the new one. Make sure you have access to the name servers of both your domains. If you’re using godaddy to purchase your domains you should be able to configure this under “Domains” -> “Domain Management” -> “Domain Manager”. We’ll talk more about this in the next step. For now, just make sure you have:

  1. FTP client (filezilla)
  2. Live site editor (Coda)
  3. Access to your hosting account
  4. Domain management tool and
  5. Sql client

Setup…

Let’s say you just bought the new domain you wish to host the wordpress site on. Let’s also say you’re using Godaddy to register domains (domain registrar). In my case, I have a Virtual Private Server that I host my sites with and I register all my sites with godaddy, so I usually point my domains at my hosting and then set up a package for each one. If you have no idea what I just said, don’t worry. Keep reading…

  1. The first thing I want to do is point my domain to the proper hosting account (if you are hosting with godaddy skip this step). I do this by going to Domains -> Domain Management ->Domain Manager -> new-domain.com and click on “set nameservers”. Point your name server to wherever you’re hosting your sites (usually ns1.yourhostingdomain.com and ns2.yourhostingdomain.com).
  2. Make sure you have a package and account setup to receive incoming requests from that domain. This is done by setting up a new package and account on your hosting server. It’s beyond the scope of this tutorial for me to tell you how to do this, but I can tell you that you will need to have this completed before your server will receive and act on requests coming from your new domain.
  3. Double check that your current domain is working properly and the site is behaving as normal.

Download the Original Site…

You will begin by opening up your ftp client and downloading your wordpress installation at your old domain. Double check that there are no failed file transfers. Once the download is complete, make sure you keep these files. This is your site backup.

You will also make an sql dump of your old domain. Do this by going into the back of phpMyAdmin or any sql client, click on the database your wish to download and click “export.” Make sure you have the settings shown in the image below and then click “Go”.

Save the downloaded zipped file to your computer and move to the next step.

Upload to the New Domain…

Now that your have downloaded your entire wordpress installation and the database associated with your site, you need to upload it all to the new domain. If you are hosting with godaddy, it should create a directory for the root of your domain. If you want your blog to appear when you type in “domain.com” then this is where you would upload you wordpress installation. If you want your blog to appear at “domain.com/blog” then you would create a folder in your root directory and name it “blog” then upload the entire wordpress installation to /blog.

Once your are finished uploading the wordpress site to the proper hosting directory you need to add the SQL Database. Create a new database on your new domain hosting account and navigate in you SQL client to that database. Click “Import” and upload your zipped sql file.

You should see a green box appear indicating a successful upload. Now you need to enter some SQL commands to change the database to operate with the new domain name. navigate to your SQL tab and begin entering:

UPDATE wp_options SET option_value = replace(option_value, 'http://old-domain.com', 'http://new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

Then enter:

UPDATE wp_posts SET guid = replace(guid, 'http://old-domain.com','http://new-domain.com');

Then enter:

UPDATE wp_posts SET post_content = replace(post_content, 'http://old-domain.com', 'http://new-domain.com');

Doing this ensures wordpress knows it’s on the new domain and won’t make links and such reminiscent of the old domain. Now we just have one more step to go!

Change wp-config.php…

So far, we’ve uploaded the wordpress site on the old domain to the new one. We’ve updated our sql to reflect the new domain name and we’ve double check to make sure our old site is still working just fine. Now we just need to hook it all together.

Open up your favorite live site editor (I prefer coda but you can use anything you like, notepad++ is a great editor if you are on a Windows machine). Connect to your new domain and navigate to your wordpress installation root. There your should find a file called wp-config.php, open it. Scroll down and enter in the new Database connection information. This will allow the new wordpress installation to connect to the new database.

Once you’ve edited the wp-config.php file. Save it and navigate to your new domain in your browser! You should see an exact replica of your old site on your new domain! Start clicking some links real quick and make sure everything is working correctly.

3 thoughts on “Moving a WordPress Blog to a New Domain

  1. Just a note to say thanks. I wanted to switch my art blog out from under my tamiross.com blog. This worked like a charm!

    Thanks so much for sharing!!!

  2. I know this if off topic but I’m looking into starting my own
    blog and was wondering what all is needed to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very internet smart so I’m not 100% positive.
    Any recommendations or advice would be greatly appreciated.
    Cheers

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.