How to Move your WordPress Website

This post has been marked as old. The code might no longer work. Comments have been disabled as this is no longer maintained.

Here's a more recent version of this tutorial.

I build most of my client’s sites on my server, then move it to theirs when it is time to launch. After doing it many times, I have developed a set of steps that helps me do the move quickly and with minimal issues.

First, what not to do: Don’t use WordPress’ Export tool (Tools > Export, from the WordPress Administration area). This often results in lost content and images that don’t work – they get put in the wrong uploads subfolder, making them not show up on your site.

If at all possible, you’ll want to actually move the database, make a few changes to the database, then move the server’s files over.

This should only be done by experienced developers. You can lose your files and content forever if you do something wrong, so make sure to always have a backup.

Move your database

On the server with the site you’re moving (which I’ll refer to as “old server”), find PHPMyAdmin in CPanel, Account Center, or whatever else your host provides for managing your website. Once inside PHPMyAdmin, do the following:

  1. On the left side, click the database that your WordPress site is using (if you’re unsure, look in your wp-config.php file at DB_NAME)
  2. On the top menu, click “Export”
  3. If this database is used only for this WordPress installation, just make sure “Save as File” is checked at the bottom and press “Go”. If you’re using the database for multiple WordPress websites, at the top-left select the tables used for this website (if you’re unsure, look in your wp-config.php file at $table_prefix).
  4. Note: if your table prefix is wp_ you should change it to something else. This is better for security, and also will prevent issues importing it into the new server. Here’s how to rename your tables.

That will export a copy of your old server’s database to your computer. Next, you’re going to upload the database to your new server. Log into phpMyAdmin on the new server, go to the database you’d like the tables added to, and click Import.

Update the Database

Now that you have the database from the old server on the new server, we have to make a few changes to it. We’ll be changing all the mentions of the old server to the new server.

I’m going to assume that your table prefix is wp_, that your old site was and your new site is Click the SQL link at the top to run the following commands.

[sql]UPDATE wp_options SET option_value = replace(option_value, ‘’, ‘’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = replace(guid, ‘’,’’);
UPDATE wp_posts SET post_content = replace(post_content, ‘’, ‘’);
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘’, ‘’);[/sql]

  1. Update WordPress Options so the WordPress site knows where it is.
  2. Update the URL’s to the pages of your sites.
  3. Find any use of the old URL inside the posts (links, images…) and replace it with the new URL.
  4. Finally, find any use of the old URL inside custom fields (example: Thesis post image) and replace it.

Move the Files

All of your customizations to WordPress are stored in the wp-content folder, so that’s really all you need to move over. Copy the /wp-content directory from the old site and upload it to the new site. If you have SSH access you could also gzip the directory which will make the download/upload process go faster (moving one file instead of many).

Now your site has successfully been moved over. The only thing left to do is update the Permalinks and Privacy settings:

  • Go to Settings > Permalinks and click Save Changes. This will create the .htaccess file so all permalinks will work.
  • Go to Settings > Privacy and set the site to visible. This is only necessary if, when you first set up the site on your server, you unchecked “make this site visible to search engines”. I recommend keeping the site invisible until you deploy it.

To summarize, a Migration Checklist

  • Download a copy of /wp-content and database.
  • Upload database to new server.
  • Find/replace domain.
  • If an existing WP install is on the server, upload the /wp-content directory as /
  • If an existing WP install is on the server, rename /wp-content to /wp-content.old. Rename / to /wp-content
  • If a new WP install, upload WordPress to the server
  • If a new WP install, delete the default /wp-content directory and upload the new one
  • Update wp-config.php with new database credentials and change the SALT keys
  • Log in and create permalinks (Settings > Permalinks, Save)
  • Turn Privacy mode off

advanced thesis wordpress

Receive New Posts by Email


  1. Hey Bill,
    I only started following you a week ago or so and, with this, you’ve already saved me a ton of work and anxiety! 🙂

    Thanks so much for this tutorial.

  2. Okay…Brilliant!…I had developed a new wordpress site for one of my existing clients with a static website. I used a subdomain on my site to do it all. Was a little worried about the move because the import/export in wp sucks…
    The only issue I had was the permalinks needed to be reset (I forgot to copy the .htaccess file). Once I copied that and refreshed…all was up.
    I especially love the sql command replacing all the oldurl to newurl…worked like a charm.

    1. I’ve followed all the instructions to the letter but my permalinks have broken… Luckily, it’s just a localhost test before I attempted to do this on the live server but I’d like to know if there are any other tricks to get the permalinks to work again. I did switch them to the default structure (which works, of course) but no other permalink structure works.

      Other than this small hiccup, your method works perfectly and it’s so simple! I was stressing out about the database move but now my only concern is if my custom permalink structure is going to work.

      1. Once migrated, did you go to Settings > Permalinks and click “Save”? After you migrate, you’ll need to regenerate the .htaccess file

        1. Hi Bill. Thanks for answering so quickly. Yes, I did regenerate the file. I actually found out that in a localhost environment there is a mod_rewrite restriction that prevents the .htaccess file from doing what it needs to do to work.

          I cloned the site on my server as a test and found that your instructions worked just fine the way they were and that it was limited to my local machine only.

          Thanks for the great tutorial!

  3. Thanks Bill! Everything worked as planned. Had a minor problem due to a plug-in and upgrading, but deleted the plug-in and everything works fine now.

  4. have you given backupbuddy a try? it makes it really trivial to move a WordPress site from dev to live.
    there’s a free alternative I’ve yet to test caleld “backup and move”

    have you already moved a network install sub-blog to a single install?

    1. I prefer to work directly with the database, so if anything goes wrong I can figure it out and fix it. But that’s just a personal preference. I’ve heard great things about BackupBuddy.

    2. I can second the Backup Buddy method (I actually like to call the plugin, “Migration Buddy”). It also now allows migration to and from Multi Site installs.

  5. “Log into phpMyAdmin on the new server, go to <> you’d like the tables added to, and click Import.”

    Thing is, there is none..on my new server. Make one? then if so..does it need to be named the same as the other db on the old server, AND- same user name for the db, etc? Why wasn’t this mentioned? Sorry for the noobness.

  6. Question re: running the commands to update the database domain mentions:

    I have developed the site in a directory on the “old site” (my domain) but moving it to the root folder of the “new site” (client domain).

    Would I modified the mentions of ‘’

    This is my first time working directly with myPHPAdmin, so I really appreciate your instructions.

    Many thanks!

  7. Sorry if this is obvious, but what I need to accomplish is moving an established blogspot site to wordpress without breaking 50,000+ backlinks.

    Is the step in this process where you discuss the .htaccess file, the relevant piece of the puzzle that ensures all your backlinks still work once you are moved over?

    Thanks for your time, I really appreciate this. I’m really glad I found your site!


    1. If your website is then there’s no way to make those links work. To my understanding blogspot won’t allow you to forward that traffic to your own domain. If you’re already using your own domain you just need to match up the permalink structure so WordPress will construct the URLs in the same way as Blogger. Go to Settings > Permalinks to set this up

  8. Pingback: Moving a wordpress site… | Manfred Krueger
  9. Hi
    I’ve got a bit of experience with wordpress, but all of the above is welcomed advice so thanks.

    I’m building a site for a client on a new server so I’ve had to assign a domain reference so I can work on it and view it etc.. When the domain is transferred everything should switch over (as it has done on a previous build). Problem is that last time all the images were missing as the file path didn’t update. For instance temp domain was then switching to just

    Wasn’t too bad last time as it was a small site with few images so just uploaded again. This time site is bigger with lots of images so want to try and save a lot of re-uploading! Any ideas how I can solve this? Thanks

    1. If you’re talking about the images inside of posts (technically, URLs in the database) then the above SQL query will fix all of these. If you’re talking about images in the actual theme file, use get_bloginfo(‘wpurl’) instead of hardcoding the links.

  10. Bill, your php script worked like a charm, Bravo! Best to your continued success.

    Jeff Gillis
    CEO & Founder

  11. any advice on moving from hosted site to a self hosted site since i can’t work directly with the data base and can only export xml?


    1. You’ll have to use the Export file. If the file is too big for export, you can either ask your host to bump up your max file size, or break the export files into many (ex: export by year, export by category… whatever gets it down below the max). I’d then recommend going through your content and ensuring all the media made it over. If it didn’t, manually add it back.

  12. Great guide. I also put up a guide, and recently moved a few installations when changing webhost. Perhaps your guide is a little easier to read

  13. Pingback: WordPress Meetup: Q&A - WP Austin
  14. My old blog was, my new blog is also, so my URL never changed when I switched hosts. (right?) I installed the sql file and everything (including plugin theme) is showing up on the blog perfectly, except the images. I see the image names in the media library, but no thumbnails or images appear anywhere in the blog. Would following your steps solve my problem with my missing images even though the URL never changed?
    My hosting company is telling me I need to change my permalinks and cant help me. So even though my URL stayed the same, something changed the links when I switched hosts? Thank you for any help, I dont know where to start!

    1. No, there’s no need to update the URLs if the URL didn’t change. It sounds like the images haven’t been moved over. If you FTP into your server and go to /wp-content/uploads and drill down into the folders (they start with year then month, so /2011/10 ) do you see any images?

  15. Pingback: Moving your WordPress site from one server to another - WP Austin
    1. The above method should work just fine for migrating from a subdirectory. Copy all the files up a directory, then update the URLs in the database.

  16. I can’t seem to import the database. I get an access denied error. I’ve tried using both the current DB name and creating a new one.

    Thanks for the help!

    1. It sounds like you don’t have the correct database login information. You should speak with your host about this issue.

      1. Thanks for the reply.
        I’m asking you only after having been all over the web on this. I appreciate your time.
        I can move the site, but it’s all messed up.
        • I did a text find/replace to change the DB URLs and changed the config file DB name, user & PW.
        • I can import a DB if I comment the “Create …” at the top of the file. Otherwise I get a “database already exists” error. I’m probably messing something up here, but don’t know what to do about it. The DB looks just like the original to me, but with the new URLs (and the Create comment).
        • All the pages show up in the new location, but the theme (FlexxPro) is messed up. My custom menu is there but Appearance/Menu now says that the “theme supports 0 menus” and no menu displays. The widgets have disappeared and Featured images have switched to defaults. As a check, Weaver displays the custom menu, but has lost the widgets and images as well. There are likely other problems, but that’s as far as I checked.

        I bravely/foolishly committed to my first WP site by next week and I can’t move it into position. I had no idea that moving the site would be so problematic. I prostrate myself before you and the WP gods for my naivete and arrogance. I’m really stuck.

        Thanks again for the help!

        1. Is the create line creating a database or the tables? If the tables, it sounds like you’re importing the new tables into a database that contains tables with the same prefix (ex: there’s already a wp_posts and you’re using the default wp_ prefix ).

          Possible fixes:
          – Just create a new, blank database to import all this into. That way you don’t have to worry about any conflicts.
          Change the table prefix
          – If all else fails, don’t use the database import method. Add the themes and plugins, use WordPress Import/Export tool to get all the posts/pages, then manually recreate everything else (widgets, menus…).

  17. Thanks again! That’s what I spent today doing. I did a new WP installation and reimported content. But that means I had to reinstall and reconfigure the widgets and all my other plugins. I hope I can figure this out and won’t have to do it every time!

    Three questions (I guess I need to learn some SQL) …
    1. The DB I exported from myPHPAdmin, has ”
    — Database: `wrd_blfacb56kk`

    CREATE DATABASE `wrd_blfacb56kk` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
    USE `wrd_blfacb56kk`;”

    at the top. After Find/Replace of the URLs, I changed the DB name in each of the three instances and imported to a new DB via myPHPAdmin, and I’d get a ” DB exists” error. Then I’d comment the “Create …” line and it would import. I thought that was it, but it wasn’t.

    This apparently worked in that the pages appeared at the new location.

    Q1: Would the pages have appeared in wp-admin just from having moved the site folder? Without the DB?
    Q2: If the new DB tracked the pages, why not the theme info?

    2. Then I turned to the WP Migrate DB plug in which generates a DB file with “CREATE TABLE …”. But it refers to the original DB name. I was so scared of losing the one working site I had, I did not implement the file.

    Q3: Is this what I need? – Change the DB name in the WP Migrate DB plugin file to a new DB and CREATE TABLE?

    Thanks again!

    1. I think you really need a database guy to look at your specific situation. Try contacting Dean Hall ([email protected]), who’s my go-to guy for database issues.

      Your DB export should not contain a CREATE DATABASE line. It should start with CREATE TABLE.

      Unless you have a functioning WP database set up, visting admin pages will just give you “Error establishing connection to database”. Bringing over the tables should bring over everything. You wouldn’t get access to posts and pages and not theme information.

      I’ve never used the WP Migrate DB plugin so I can’t comment on how it is used. But when you export your tables it should be database-independent. Once exported, I open phpMyAdmin on the new server, select the database from the left, then click “Import” at the top and import the sql file. It’s this part that determines what database it goes in – not anything in the sql file itself (unless you have a CREATE DATABASE in there, which you shouldn’t).

  18. Thank you so much! I’ve only manually edited the options table and done the rest in WP, which leaves a lot of room for error! You’re my hero!!

  19. Thank you so much for this post! Just wanted to share this from a while back on WordPress Answers; Rarst says doing plain text search/replace will potentially break serialized data (as is used for a lot of widget settings I think?).

    I’d never experienced that as a problem but I’ve taken to using the php file available at Interconnect IT’s site to do the search & replace anyway as it’s faster/easier than going into phpMyAdmin.

    Thanks again for the great tutorial 🙂

    1. Yes, it will definitely break serialized arrays, which is why the SQL statements I put above don’t apply to serialized arrays (unless you’re using them in postmeta, which I’ve never done).

      The only area that I find this being an issue is in widgets, so I use shortcodes for URLs in widgets. [url] is the Site URL, to be used if you’re linking to pages. [wpurl] is the WordPress URL, to be used if you’re linking to files in WordPress (ex: images in the uploads folder). and [child] links to the child theme directory.

  20. Bill

    Thank you for this great tutorial. It worked like a charm for me with a clients website. I was on this issue for about four hours this morning. I am not big on databases but this was very easy to understand and to the point. If I can give you a hug right now I would! Thanks again for your help.

  21. I just moved my xampp localhost/wordpress installation to my hosted webserver. Followed all the steps in the your tutorial (great by the way). Everything looks okay once I log into my WP account on my new webserver — all the posts/pages are there in Edit mode.

    However, when I go to Preview them or go to the url, all I get is a blank page. Why would everything look okay in Edit mode, but not appear in Preview or when going to the url? This is the root of my problem, but I can’t seem to figure it out. Any idea or suggestions to check where I might check things out? TIA, Judy

    1. Have you tried going to Settings > Permalinks and clicking Save? You need to regenerate the rewrite rules once you migrate the site.

      If that doesn’t work, try switching to the default rewrite rule from that page. That will tell you if your server is having an issue with rewrite rules or not (if default works, it is a rewrite issue).

  22. Hi,
    One question, I am running my site/blog on a shared server and right now the size of database is more than 2MB in size. I am afraid how i can import the same database using phymyadmin on a shared hosting. Do you have any idea how to solve this problem. ~rakesh kumar

    1. When exporting the database, you can usually select the type of compression. The default is .sql (no compression), but if you use one of the compressed formats it decreases the size substantially. That usually gets you under 2mb filesize.