Moving A WordPress Site

I recently moved this WordPress site from www.lexclab.info/WebProg to www.epiphenie.com. Both domains were located on the same server, using GoDaddy Linux Shared Hosting. Some of the instructions below may change for your particular install, but the general procedure should be the same.

For this tutorial, I am using the following programs and technologies:

  • [GoDaddy] Linux Shared Hosting
  • Chrome Web Browser
  • [FileZilla] FTP Client
  • [Komodo Edit] – text editor

It is also assumed that you are moving your site within the same server. I have not tried these instructions when moving to a different server or a different hosting company.

1. Create A New Folder

If you are moving your site to the root directory of an existing domain, you can skip this step. If you are moving your site to a new sub-directory in your domain, you will need to create that directory.

I created my directory using the FileZilla  UI. Just right click inside the folder where you would like to insert the new directory and select “Create Directory”. If you are using GoDaddy’s File Manager, click the “Create New Directory” link on the left column above the directory structure.

2. Back Up Your Database

It is VERY important to back up your database. If you inadvertently change something that you did not mean to, you can always revert to your last-saved version of the database. I’m assuming you know how to do this for your particular system. If you don’t know how, go to your database and learn NOW!

Using GoDaddy, go to Hosting Control Center > Databases >mySQL. Click on the correct database and click the “Edit/View Details” button. Click on the Backup button and prepare to wait up to 2 hours.

3. Back Up Your Files

Again, we are going to be screwing around with this stuff and moving it to a different location. You MUST back up your files. If things go terribly wrong, you need to be able to restore things to the way they were. I had over 80 posts on my site when I moved it. Backing up your files means you will copy the entire directory from your server to a local drive. If you like, zip the file to save space when you’re done with this process. This could take some time, so be prepared to wait. This is easily done using your FTP client. Again, I’m assuming you know how to do this type of operation.

4. Update Your WordPress Settings

Log in to your blog site and go to the Admin > Settings > General page. Change your WordPress address (URI): and Site address (URL): to reflect your new page settings. You might want to change your Blog name as well.

5. Move Your Files

There are two ways to move your files. The first is to move the files completely online and the second is to move all of your files to a local drive and then copy them back up to your new directory. If you do this, make sure you delete the old files.

If you are using GoDaddy’s File Manager, navigate inside the old folder and select all of the files. (If you have multiple pages of files, you may have to do this more than once.) Select the “Move” button and then select the new directory. Note that this only works if the old and new folders are located on the same server. If you are using an FTP client, check that it allows moving. FileZilla does not. If you’re using FileZilla, you’ll need to make a new local copy of all of your files because you made changes in Step 4. You can then copy those changes to the new directory.

6. Update Your Permalinks

If you are using Permalinks, log into your new page and go to the Admin > Settings > Permalinks page. Update your Permalink structure to reflect the desired structure of your new page.

7. Update Image Links

This is the most complicated step of the process. When you update images in your site using the WordPress UI, your images were saved to www.oldsite.com/olddirectory. Now the site has been updated and the pages all point to www.newsite.com/newdirectory.

Update

If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options, from WordPress.org:

  1. Only perform a search and replace on the wp_posts table.
  2. Use the Search and Replace for WordPress Databases Script to safely change all instances. ( If you are a developer, use this option. It is a one step process as opposed to the 15-step procedure below )
  3. Optionally, you can also use an online tool (in case you don’t want to bother with uploading scritps to your server) Online WordPress Serialized PHP Search and Replace which allows for replacing an old domain or URL with a new one while fixing the serialized data at the same time.

Old Information

  1. Export your Database, making sure that the files are written so that “CREATE TABLE” is “CREATE TABLE IF NOT EXISTS” and that “INSERT INTO” becomes “REPLACE INTO”.
    1. Using GoDaddy, go to Hosting Control Center > Databases > mySQL > Manage via phpMyAdmin.
    2. Login and click on the “Export” link on the entry page.
    3. In the Export column, click on the database name, not the information_schema and make sure SQL is selected.
    4. Under “Structure”, check “Add IF NOT EXISTS”.
    5. Under “Data”, change “Export Type” to “REPLACE”
    6. Keep everything else as the default and click “Go”.
  2. Save your database export to a local file.
    1. Using GoDaddy, the export will appear in a text window. Copy all of that data to your clipboard (Ctrl +A and Ctrl +C).
    2. Open a new SQL file in Kimodo Edit.
    3. Paste the data.
    4. You may need to change the format of the file to be able to save. Go to Edit > CurrentFileSettings and make sure the Encoding is set to UTF-8. My default was Western Europe CP-1252. That failed miserably.
    5. Save the database.sql file. (Or any name that you like.)
    6. Rename the newdatabase.sql file. This makes it easier to revert if you need to for errors.
  3. Do a Find/Replace to update the necessary data. Depending on your site size, this could take some time. Don’t over click and crash the program.
    1. In my case, my find was: “lexclab.info/WebProg/wp-content/uploads”
    2. My replace was: “epiphenie.com/wp-content/uploads”
    3. Save newdatabase.sql.
  4. Import the new database SQL file into your database.
    1. Using Godaddy and still in Hosting Control Center > Databases > mySQL > Manage via phpMyAdmin, go to your database and click on the “Import” link.
    2. Locate the .sql file and leave all of the defaults.
    3. If there is an error, you will need to address it. I didn’t have any errors.

Check your webpage for any errors. If you had made any custom image changes and hard-coded images in your code, you will need to change those in your files and use your FTP client to update them.

8. Update Image Settings

Go to Admin > Settings > Miscellaneous and update your file upload settings.

Mine was a relative path, but I updated it just in case the background set the hard-code path.

9. File Permissions

In some cases your permissions may have changed, depending on your ISP. Go through your FTP and watch for any files with “0000” permissions and change them back to “0644”.

10. Menus

If your theme supports menus, links to your home page may still have the old subdirectory embedded in them. Go to Appearance::Menus and update them.

11. Link Your Old Site

Make sure you go to your old site and fix the links that pointed to your WordPress site. One easy way to do this is to create a PHP Redirect.

In my case, the old site was a sub-directory, \WebProg. I created an index.php file with the following content:

<?php
header(‘Location: http://epiphenie.com/uncategorized/this-site-has-moved/’);
?>

This automatically redirects any users typing in the URL of your previous location. This is the quickest and easiest method.

12. Troubleshooting

If you have any problems with this tutorial, please see the [Wordpress] documentation .

UPDATE: This article was published in the summer of 2010. To make sure you have the most relevant and up-to-date information see the WordPress Codex for Moving WordPress.

Author: Steph

Share This Post On

Pin It on Pinterest

Share This