HowTo – WordPress – Moving Your Blog To Another Location

Filed under: Wordpress Tips

wordpress-logoThere are times when you need to move your site either within your current hosting or to a new website hosting company. When you do this there can be problems if you do not follow a few simple rules.

First before you ever do anything like a move you want to backup your database.

Backup Your Database
Backing up your database requires full backup of the MySql Data and not just the post content that you can export.  Exporting is fine if you want to start from scratch and then import only your content but you will lose a lot of settings including the setups for your plugins, sidebars and account options.

If you are moving from a host where you can only export through WP then you should export all your data and export the WP Database with a Backup Plugin if you have access to it.

Backup Your Files
You also want to backup all of your files but before doing so if you use WP-SuperCache you want to delete the cache and set the plugin to off. There is never a reason even during general backups to backup cached files if you know your data and site is in good working order. Delete them and then let them be regenerated.

Install WordPress on your New Site
If you have a full backup of your files just copy them by ftp or through your hosting control panel to their new location.  Make sure your FTP ap is able to recognize Binary and ASCII file formats.

Make a New Database & Import Your Data
When you move to your new site you will need to make a new database shell for your WordPress Database info to live in.

The easiest way is to use the same database name but if your account name has changed cPanel will use your new account name as a prefix for your database name example.

Old Host
Account Name: tonyx
Mysql DB Name: tonyx_wpdatabase

New Host
Account Name: bigtony
Mysql DB Name: bigtony_wpdatabase

REMEMBER when you make your new database go into the User Rights and give bigtony full rights to the database read wright drop add and so on.

Make sure you catch the new name of the database and any changes to the database user if they also prefix that name and change them in your wp-config.php file.

IMPORT your database into the new database you made. There should be an option in your control panel to import an old database or restore a backup into the database you just made.

Making WordPress Work on the New Host

Once your files and database are in their new location try to access WordPress and see if there are any errors. If you have not changed the locations of files or the domain name then everything should work if not then you will need to edit the locations in your WordPress Database.

THE EASIEST WAY TO DO THIS IS AUTOMATICALLY

Open your WordPress wp-config.php file and at the second line right after <?php add this

define(‘RELOCATE’,true);

WordPress will now try to read all your settings at your new host and configure your blog and url setting.

Try accessing your WordPress install and see if everything is working If not you may need to make these changes in a different way.

Changing your Location Settings in the WordPress DB
If Auto Relocate did not work for you the next option with the least difficulty is to add commands to your WordPress wp-config.php to make the changes.

Open your wp-config.php file and on the second line after <?php add the following and make changes to these lines to fit your site.

update_option(‘siteurl‘,’http://www.example.com/’);
update_option(‘home‘,’http://www.example.com/wpfiles‘);

Remember siteurl is where your visitors access your WordPress site it is where your index.php file is  so change the site url to meet that location.

This index.php file contains the following and can be placed in your main directory if you want to put your WordPress core files in a subdirectory use this format.

<?php
/* Short and sweet */
define(‘WP_USE_THEMES’, true);
require(‘./wpfiles/wp-blog-header.php’);
?>

The Home Location is where the WordPress Files are and that directory contains the wp-config.php file

Your .htaccess file

The WordPress .htaccess file has changed from including specific information to generic over the years so you probably won’t have any problems with this file unless you have made changes such as restrictions on directory indexing and image hotlinking.

If you have altered your Permalinks or Modified your .htacces file or if your plugins have added information such as wp-supercache plugin you may want to regenerate this file.

Keep your backup and delete the file

Go into your permalinks settings and resave them.

Then turn off and turn on your plugins that use this file.

Finally make any personal modifications that you need to make.

Final Thoughts
This is the end of basic migration or movement of your WordPress install. If you have not got use to editing your database up to this point you should look into phpMyAdmin and learn how to use it for backups, restors and modification of database data.

If worst comes to worst then you may be able to use your cPanel or other control panel to install a fresh copy of WordPress. This will setup all the database information and the admin account.

At that point you can import your exported posts from your previous site and begin the process of uploading your theme and plugins.

If you are moving from a hosted account on WordPress.com then you should make sure you have access to the Theme file that you were using on your free account so you can use it on your own server.

You should also look into how to setup a wordpress install on your home computer. This is a pretty easy thing to do with the XAMPP server install package for Windows or for other operating systems.  Having a home development server to test your modifications and to learn is the best way to do things without causing downtime for your visitors.

for more information visit http://codex.wordpress.org