Moving A WordPress Website Without Hassle By Rachel McCollin

Posted on Eki 2, 2013 by in Blog | 0 comments

Bu makale Rachel McCollin tarafından Smashing Magazine için yazılmıştır. Makalenin orjinaline buradan ulaşabilirsiniz…


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 multisite installations, just for standard single-site installations.

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.

1. Remove the Existing Website

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!

2. Turn Off Permalinks

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.”

Larger version.

3. Change Your Website Address

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, change the settings as follows:

  • WordPress address (URL):
  • Site Address (URL):

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

4. Copy and Edit Two Files

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) this:

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

So if you’ve been developing in, just change the line to:

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

Save the new index.php file.

5. Turn Permalinks Back On and Test

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.

1. Turn Off Permalinks

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.”

2. Backup the Database

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

3. Install WordPress In the New Location and Upload Content

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.

4. Edit the Database

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

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

5. Drop the Existing Remote 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”:
  • 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:

    Larger version.

6. Upload the New Database

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:

7. Clear Your Browser’s Cache

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

8. Log Into the WordPress Admin For the Remote Website and Update Permalinks

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:

2. Download and Backup the Old Database and Files

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 the index.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.