Moving A WordPress Website Without Hassle

Moving WordPress is a task that many people find daunting. The advice on the Codex, while comprehensive, gives you a myriad of options and doesn’t describe the process simply and in one place.When I had to move a WordPress installation for the first time, I spent hours searching online for information on the various aspects of the process, and eventually wrote myself a checklist — which I still use.

So to save you the hassle, here’s a step-by-step guide to moving a WordPress website. I’ll cover three different scenarios, which in my experience are the most common:

  • Moving a website from a subdirectory of a domain to the root directory (for example, if you’ve been using a subdirectory for development while not affecting an existing website that’s in the root);
  • Moving a website from a local installation to a remote installation; and
  • Moving a website between domains or hosts.

Before You Start

Before you start any of these methods, make a backup of your website:

  • Your theme files;
  • Your uploads;
  • The plugins you’ve used, so you won’t have to spend time downloading them again if things go wrong; and
  • Your database.

You can back up the database using one of a number of tools:

  • phpMyAdmin;
  • Sequel Pro for OS X;
  • Terminal commands;
  • A MySQL desktop client; or
  • A backup plugin such as WP-DB-Backup, which will provide you a copy of your database by email or download.

In this article I’ll show you how to back up your database using phpMyAdmin, as this is provided by most hosting providers and has a relatively easy-to-use interface.

If I’m going to be editing the database (which needs to be done when uploading a website or moving it between hosts or servers), I start by making a duplicate of the database and adding “old” to its name. This is the backup, and I’ll be editing the original database.

Moving A Website From A Subdirectory To The Root

This is by far the simplest of the three moves I’m going to cover, because you don’t actually have to move anything — or nearly anything. This method will work on a standard installation of WordPress, and will work with most frameworks, or if you’re using a parent and child theme structure.

Beware! This method will not work for:

  • Multi-site installations; or
  • Sites using Genesis as a framework (or so I’m told, I haven’t tested it myself — if you can get it to work please leave a comment below).

The great thing about this method is that it only takes from three to ten minutes depending on your setup — no time at all in the scheme of things.


If there is an existing website in the root directory, remove it. It may be another WordPress installation or it may be a static website.

If it’s a WordPress website, make a backup as detailed above, and then delete all of the WordPress files in the root.

  • If you have access to Softaculous or another installation service via your hosting control panel, use that to uninstall WordPress.
  • If not, use phpMyAdmin to drop (delete) the database from the existing website. See the next section for details of how to do this.
  • After dropping the database, remove all WordPress files. This normally means any files or folders beginning with wp-.
  • Beware — don’t remove the existing site until you have made a backup!


Turn off pretty permalinks in the “Permalinks” screen, which you’ll find in the “Settings” menu. Do this by selecting the “Default” option and clicking “Save Changes.”

Permalink Settings screen.
Larger version.


In “Settings” → “General,” change the address of your website but not the address of WordPress. For example if you’ve been working on the website at example.com/development, change the settings as follows:

Save by clicking on the “Save Changes” button and move on to the next steps before trying to access your website.


Using FTP/SFTP or cPanel file manager, copy (don’t move) the following files from your WordPress directory to the root directory:

  • index.php
  • .htaccess, if you have one. If there isn’t an .htaccess file (and turning off pretty permalinks means you’re less likely to have one), don’t worry about creating one.

Edit the index.php file that you’ve moved. You could do this by:

  • Editing it in situ after the move, by using FTP/SFTP or cPanel file manager;
  • Downloading it from the subdirectory, editing it and then uploading it to the root directory — instead of making a copy.

The edit you need to make is very simple, to one line at the end of the file. You simply change this:

require ('./wp-blog-header.php)

..to this:

require ('./subdirectoryname/wp-blog-header.php)

So if you’ve been developing in example.com/development, just change the line to:

require ('./development/wp-blog-header.php)

Save the new index.php file.


Back in the WordPress admin, turn pretty permalinks on again, with whatever setting you need for your website.

Visit the root domain of your website in the browser and it will display the website that’s stored in the subdirectory, but the URL will show the root URL rather than the subdirectory URL. And that’s it!

Uploading A WordPress Website From A Local To A Remote Installation

This is one of the most common instances of moving WordPress. If you’re working on a local website for development and need to upload it either to go live or because you need to show a client or other team members your work, you’re going to need to upload your WordPress website. This is more complicated than moving from a subdirectory to the root directory, and involves moving three things:

  • WordPress itself — you’ll need to install this in the new location;
  • The database — which you can move using phpMyAdmin;
  • Your theme files, uploads and plugins.


Turn off pretty permalinks in the “Permalinks” screen, which you’ll find in the “Settings” menu. Do this by selecting the “Default” option and clicking “Save Changes.”


Make a copy of the database and give it a new name (for example, by adding “old” to its name).


Using your preferred method, install WordPress on the server you want to move your website to.

Using FTP or SFTP, copy the files from your local “wp-content” directory to the remote “wp-content” directory, using the same folder structure as in your local install.

Go and have a cup of coffee. These files could take a while to upload.


Don’t just open the original database file from your local installation and edit it. DB ata stored serialized will break if edited directly in a text editor. You are better off with a serialize-aware tool like Search-Replace-DB (thanks, Andrey Savchenko!). Replace the old, local URL for the website with the new, remote URL.

So for example, if your local URL is http://localhost/example, you would change it to http://example.com.

Using the “replace” command will speed this up — there could be thousands of instances. Save your new database.


Note: This step only applies if you’ve used a script such as Softaculous or Fantastico to install WordPress, as they automatically create a new database. If you’ve installed WordPress manually, you can ignore this bit.

In phpMyAdmin, drop (delete) the database that was installed in the remote website when you installed WordPress:

  • Select the database you’re working with.
  • Click on the “Structure” tab.
  • Below the list of tables, click “Check All.”
  • In the drop-down menu which says “With selected,” select “Drop”:Dropping a database in phpMyAdmin.
    Larger version.
  • You will see a warning message checking that you want to drop all tables. Click “Yes.”
  • Finally you will see a message telling you that your query has been implemented:Confirmation message after dropping a database.
    Larger version.


While you are still in phpMyAdmin, upload the database you’ve edited:

  • Click the “Import” tab.
  • Click the “Choose file” button.
  • Select the database you saved in step 4 and click “Choose” or “OK.”
  • Click the “Go” button.
  • After a while (depending on the size of your database), you will see a message telling you the upload has successfully finished:Confirmation message after importing a database.


This avoids any problems you may have if the browser has cached content from the old version of the remote database.


Your log-in details will be the same as for your local website. If you specified different log-in details when installing remotely, these will have been overridden by the imported database.

Visit the “Permalinks” screen and turn pretty permalinks back on.

You’re done!

Moving A WordPress Website Between Hosts

This process is almost exactly the same as that for uploading a website from a local installation. The only difference is that you need to download the files and database from the existing website.

Follow the above process, with changes to step 2:


In phpMyAdmin for the old website, select the correct database and click on the “Export” tab. Download the database by clicking the “Go” button. The database will download to your machine.

Move the database out of your downloads folder to somewhere useful and make a copy of it. You’ll be working with this database in Step 4.

Using FTP or SFTP, download the contents of wp-content from your old website. You will upload this to the new website in step 3.

Now return to the original process.


Moving WordPress doesn’t need to be complicated. As long as you follow the steps above in the right order, your data will be safe and your website will work in its new location. Important points to remember are:

  • Always back up your website before you start.
  • If moving WordPress within a domain, you don’t need to move the whole thing, just make some changes to the settings and move and edit theindex.php file.
  • When uploading your database to a new location, make sure you upload the version that you’ve edited with the new URL, not the backup version with the old URL. Otherwise, at the very least, internal links will break and it’s possible you’ll see the white screen of death when you try to install your website.

If at any stage you go wrong, undo what you’ve done and start again with your backup. You did make a backup, right?


The WordPress Codex includes resources that will help you apply this method whatever your hosting setup:

For help with phpMyAdmin, see phpMyAdmin’s documentation.

There are also plugins which will help you move WordPress if you don’t want to do it all manually. I haven’t tested all of these, so I can’t vouch for their reliability or ease of use. If you do use one, do so with care.


Rachel manages Compass Design, a web design agency in Birmingham, UK specialising in mobile and responsive WordPress development. She’s also the author of ‘Mobile WordPress Development’, a comprehensive guide to making yourWordPress site mobile-friendly, published by Packt.

Every other Tuesday we send out our lovely email newsletter with useful tips and techniques, recent articles and upcoming events. Thousands of readers have signed up already. Why don’t you sign up, too, and get a free Smashing eBook as well?

Sign Up!

  1. 1

    Some pretty good tips, but have to acknowledge that doing a simple find and replace in the SQL file for the site URL can break settings (mainly widgets and some plugin meta data).

    I suggest using this script to safely swap out any serialized strings/arrays, and remove the chance of losing settings during the switch.




  2. 2

    A great summary but thought I would just point out one issue which I discovered recently.

    When you do a simple find and replace in the database for the domain name, if the domain is stored as serialised data anywhere, like post meta, it may corrupt the value.

    I found this article by Interconnect IT about this issue and a useful script they developed to find/replace in a safe way.



  3. 3

    Thanks for your article. Just wanted to mention the wp-migrate-db Plugin (http://wordpress.org/extend/plugins/wp-migrate-db/), which allows you to backup your DB, while change your URLs and absolute pathes.



  4. 4

    Viktor Solovey

    April 8th, 2013 8:23 am

    4. Edit the Database – it can kill serialize (http://php.net/manual/ru/function.serialize.php) values in the wp_options or wp_postmeta table in DB. so, think twice. You do no need “replace” URL for ALL tables in the DB maybe only for wp_posts.

    Thank you



  5. 5

    That seems like a bit of a runaround… The Duplicator plugin does this much more easily.


    You just create a Zipped package on your dev server, upload the folder by FTP to the new location, give the plugin your database credentials, and boom – you’re done.



  6. 7

    Luke Stevenson

    April 8th, 2013 8:38 am

    There is a (free) WordPress Plugin which automates all of this for you. Duplicator – https://wordpress.org/extend/plugins/duplicator/.
    I have used this a pile of times for moving WordPress installs between servers and domains. It seems pretty much bullet- (and idiot-) proof in my experience. And so much simpler!



  7. 8

    You missed BackupBuddy. I’ve moved loads of site seamlessly with it, I’d thoroughly recommend it. And no, I don’t work for them, honestly…



  8. 9

    Excellent resource, thanks Rachel!



  9. 10

    Vitaly Friedman (editor-in-chief of Smashing Magazine)

    April 8th, 2013 8:51 am

    Thanks to everyone for the feedback! The section on editing the database was updated! Sorry for any inconvenience caused.



  10. 11

    anonymous berlinerin

    April 8th, 2013 8:53 am

    Just in regard to editing the database, it’s possible to make a mess of things doing it that way, particularly with serialised data, e.g. if you’re using Advanced Custom fields and have stuff in repeater fields, or just having widgets and other things disappear and having to reset them.

    I’ve been using WordPress Serialized PHP Search Replace Tool for the past year and it’s deals with this very nicely.

    Also there can be occasionally be references to absolute paths in the database, so it’s good to change those also.



  11. 12

    Christopher McInerney

    April 9th, 2013 1:00 am

    Great article, could of done with it about 2 weeks ago when I had a whole host of issues exporting and importing databases. Thanks!



  12. 13

    I use wordshell (from wordshell.net) for this kind of operations. As wordshell is a command-line tool it is easy scriptable so you can fully automate the whole procedure, less change for errors or oversights.
    It btw also makes the management of wordpress plugins, themes, backups and what have you extremely easy. Not only for one site but in principle an indefinite number of local of remote sites. Not free but worth every penny.



  13. 14


    I’ve used BackupBuddy for backing up and moving wordpress sites. While it isn’t cheap, I did a simple calculation.

    I can do a WP move with BackupBuddy in less than 15 mins compared to doing it manually which would take a couple of hours.

    In relation to what I’d charge per hour and number of times I’ve done a backup, backupbuddy works out waaaaaay cheaper in the long run.

    Btw, I’m not associated with the company at all, I’ve just used it a couple of times and found it really handy.

    Hope this helps,




    • 15

      I’ve found the most time it takes is actually pulling the data from the old host to the new one. The actual transfer/import and startup usually only takes me about 2 minutes on average?

      But if there is a tool out there that makes it easier then definitely use it 🙂



  14. 16

    I just performed a move that involved Genesis. Just copy/pasted the site essentially over to the new host. Imported the Database and *poof* it was ready to go. You do have to make sure you backup and restore the entire WP Content directory though to ensure that all of the settings are saved.

    One thing to note though – I did have a “fresh” install of WordPress on the new host.

    I did have to go into the database SQL backup file and change the user name to the person who was going to be using the site (same password).

    I would suggest that you temporarily change the WordPress admin password to something simple for the move then changing it after it has been successfully moved over to the new host.



  15. 17

    Great guide! I only wish I could have read it last week before I broke the record for fastest time to break a page.ly hosted WP installation. It can be a daunting task for a newbie like myself. It can’t be said enough: Back everything up! In the absence of certainty:security.



  16. 18

    George Lerner

    April 9th, 2013 8:24 pm

    I have used BackWPup successfully, to back up both the database and all files. Works for WP Multi-Site. Good error reporting, rare among plugins and essential for backup (for example, tells that it doesn’t follow a folder when it is a symlink, or if it retried to make the .zip file due to a timeout).

    I learned how to move a WordPress site into WordPress Multi-Site, with all the site, widget, user, comment, SEO, and page settings intact. It’s complex… but if you have a lot of pages with SEO, or other settings, it’s a lot easier than putting all those customizations back in by hand! I’ll probably never have a “step-by-step guide”, since it takes many MySQL queries and either meticulous text editing or good PHP programming to do it, so contact me at http://glerner.com/contact.php if you need that done.



  17. 19

    Instead of doing all of this yourself, either use Duplicator or BackupBuddy (both will make your life a whole lot easier).



  18. 20

    I Agree with AC – far too much trouble. (and far too easy to make a mistake and stuff it up!)
    Seems to defeat the purpose of why we program!
    I use BackupBuddy as I move a lot of sites, but Duplicator works well too…



  19. 21

    Checkout this WordPress backup solution that backs up your site for free and you don’t have to set it up yourself. And optionally, you can pay a monthly fee to Update your WordPess core files and plugins, monitor your website for Uptime, get email reports with website traffic statistics, and update your website menus and content: http://www.wp-monitor.com/



  20. 22

    If you have SSH access between your hosts you can also use rsync. I’ve been doing this recently between my local and final production. It’s much faster than waiting for sFTP to transfer everything.



  21. 23

    Ojassvi Chawla

    April 14th, 2013 8:14 pm

    Thanks Rachel, I was looking for the same.



  22. 24

    Beware! This method will not work for: Sites using Genesis as a framework (or so I’m told, I haven’t tested it myself — if you can get it to work please leave a comment below).

    Genesis are no different to other themes when it comes to moving WordPress.

    WP Migrate DB plugin is free and does exactly the same thing as premium plugins like BackupBuddy.



  23. 25


    May 3rd, 2013 1:28 pm

    You guys definitely need to check Infinite WP. Backup & Cloning websites with 3 clicks, No Code, No SQL. Easy.



  24. 26

    Patrick Campbell

    May 28th, 2013 10:28 pm

    You know what I like to do?

    Just move the folder and add this to wp-config.php:




  25. 27

    Thank you thank you thank you for posting this!!!!!

    I was struggling with this and thought, someone has to have done this before. I am so grateful to have been able to learn quickly through your experience.



  26. 28

    I thought this was wonderful – at first. Easy as pie. Then I tried to see a draft of a post or page and I no longer have permission to preview drafts. I developed inside a folder and then followed the first set of instructions above (Moving A Website From A Subdirectory To The Root).

    Did anyone else have this problem and is there a fix?



    • 29

      Rachel McCollin

      June 7th, 2013 1:39 am

      Hi Cindy,

      I’m puzzled by this as moving from a subdirectory to the root shouldn’t affect your drafts or permissions at all. I can only guess it’s something to do with your hosting setup and/or your read/write permissions. You may want to speak to your hosting provider and check your .htaccess file. It’s also worth refreshing your Permalinks settings by visiting the Permalinks screen and saving your settings (you don’t have to change anything). Sometimes that works.

      I hope that helps!



    • 30

      Rachel McCollin

      June 7th, 2013 1:42 am

      Thanks for all the comments – I agree that there are plugins etc. that do this but some of them cost money and a lot of people like to be able to do things manually, oir at least understand what’s going on if they don’t actually do it themselves.

      Personally I’ve done this hundreds of times and never had any problems but thanks for the tips from those of you who have and for your suggestions too.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s