Menu Close

Moving WordPress, the quickest way

default

If you are moving WordPress to a new server or moving it to a different location on your server, you don’t need to reinstall. WordPress is quite flexible enough to handle all of these situations.

Moving to a New Server

If you are moving WordPress from one server to another, start by backing up your WordPress directory, images, plugins, and any other files on your site as well as the database. The easiest way is using a program such as FileZilla or FlashFXP and downloading the entire WordPress directory. To download the database simply login to phpMyAdmin and Export the database.

Once both of these are done, start by uploading the WordPress directory to the new server and creating a new database to import the database using phpMyAdmin. Once both of these are complete, open up wp-config.php file and change the database username, database name and database password to the new database you created on the new server.

If your previous website was on old-website.co.uk/demo and you’re moving it to silvawebdesigns.com for example, your .htaccess file will look as below:-


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /demo/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /demo/index.php [L]
</IfModule>
# END WordPress

Change this to:-


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

This will point your website to the root directory as opposed for looking for your WordPress files in the /demo/ directory.

One final thing you need to do which will speed up transfers from server to server is this next part. A lot of developers will simply just login to the WordPress Control Panel and go to Settings –> General and change the WordPress Address (URL) and Site Address (URL) as shown below:-

I don’t recommend doing this.

This will update the site and get everything to work but all the links, custom links, links within posts will remain as the old domain address. It is far easier and quicker doing this change using MySQL. All you have to do is log in to phpMyAdmin and run the following three SQL queries:-


UPDATE wp_options SET option_value = replace(option_value, 'OLDSITEURL', 'NEWSITEURL') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'OLDSITEURL', 'NEWSITEURL');

UPDATE wp_posts SET post_content = replace(post_content, 'OLDSITEURL', 'NEWSITEURL');

Just replace OLDSITEURL with the old domain name (e.g. http://old-domain.co.uk) with the NEWSITEURL (e.g. )

Run all three SQL commands separately and it will update every old URL you have in your entire WordPress site. Once you have run this, go to your new domain URL and you should find that everything is working 100%. We have done this with over 50 WordPress websites that we have transferred from my personal web hosting for our clients web hosting and never had a problem doing it this way.

If you are unsure about anything, feel free to get in touch by sending an email to hello@silvawebdesigns.com or leave us a comment on this post.

Moving Directories On Your Existing Server

If you are moving your WordPress files from one folder to another, or from a sub-directory to the root directory (e.g. silvawebdesigns.comk/demo to silvawebdesigns.com). You can simply move the WordPress directory from /demo/ to the parent folder (which in our case is the root directory). Then simply run the following three SQL queries in phpMyAdmin:-


UPDATE wp_options SET option_value = replace(option_value, '/demo', '') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, '/demo', '');

UPDATE wp_posts SET post_content = replace(post_content, '/demo', '');');

and you’re done!

There are many alternative ways to move WordPress between directories on the same server and moving them to different servers, but we find this method the best out of all the ways we have come across.

View Source
Posted in WordPress