Moving wordpress using the ezmigrate plugin
Following up on my rather complex post about how the ezmigrate plugin came to life, this will be a simpler tutorial style post in which I will explain how to actually use the ezmigrate plugin to move or migrate your wordpress installation.
Keep in mind that some plugins might not work and need additional configuration changes after you have moved your blog. Please let me know about them.
I will distinguish between two types of migration: Only changing the url and moving to a new server.
Changing the url
You will only change the url to your wordpress installation. The code and database will stay on the same server. If you’re moving to a new server, please scroll down to “Moving to a new server”.
- Install the ezmigrate plugin (when it’s not already installed).
- Make the url change. For example by moving or renaming the wordpress directory or creating the new domain name and point it to your installation.
- If you are using a caching plugin: empty or delete the cache folder(s).
- If you are using Permalinks: go to the Administration > Settings > Permalinks panel and update your Permalink structure to your .htaccess file, which should be in the same directory as the main index.php file. (Text copied from the wordpress codex).
That’s it. There is no need to change any settings or do a search and replace in your database.
When you’ve moved to a new domain name and you don’t use any caching tool you will find that your wordpress installation still works on your old domain name as long as it still exists.
When you do use a caching tool and still expect visitors on your old domain you will need to make sure your old domain name will redirect to your new domain to prevent the cache from filling with pages containing old urls. This can be achieved for example by placing the following code at the top of the file wp-config.php:
if ($_SERVER['HTTP_HOST']!='www.newdomain.com') { header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.newdomain.com'.$_SERVER['REQUEST_URI']); exit; }
Moving to a new server
- Install the ezmigrate plugin (when it’s not already installed).
- Get a backup of your database by using any of the methods described at: http://codex.wordpress.org/Backing_Up_Your_Database
- Download all of the wordpress files to your local computer.
- Edit wp-config.php and change the database settings for the new server.
- Upload all of the wordpress files from your local computer to the new server.
- Place your database backup into the new database by using any of the method described at: http://codex.wordpress.org/Restoring_Your_Database_From_Backup
- If you are using a caching plugin: empty or delete the cache folder(s).
- If you are using Permalinks: go to the Administration > Settings > Permalinks panel and update your Permalink structure to your .htaccess file, which should be in the same directory as the main index.php file. (Text copied from the wordpress codex)
Again: There is no need to change any settings or do a search and replace in your database.
Related articles:


I use this wordpress plugin version 0.6, works great, except when I change permalink in edit post menu, i get errors when preview the edited post. It can not update the permalink structure once established. Sometimes this thing happens ,sometimes doesnt. I have tried to upgrade it to version 0.8, but the error just getting widen to url error in wp-admin…it had falsely looking for wp-admi folder, not wp-admin folder.
I need to look at version 0.7 which is hard to find on download website.
@Robert: In the new version 0.9 a critical fix has been made. Please try this version and let me now whether you still experience any problems.
I wonder what you would charge to deploy the plugin and activate several URLs?
Hi,
Hope this isnt too stupid of a question:
If I want to essentially COPY a site from one domain to another (but change the content on the new domain), which approach do I use (new url or new server) if any?
What I want to accomplish in the end is to take an existing site/blog that I like (with all its themes, plugins and widgets, posts, permalink settings etc that are already configured) and copy it to a new URL. Once there I will edit this ‘new site’ to be new and unique (i.e. new content, new links, new SEO tags etc)….I’m trying to simplify and speed up the process of creating new sites by copying old ones that I’m happy with and then simply edit the content to be appropriate for the new site topic…
I find it a slow and tedious task to manually create a new WP blog on a new URL then essentially duplicate all the plugins, themes, settings (etc) in order to make it work as well as one I already have operational. I hope your plugin can help with this!
Thanks in advance,
Carrick
@Will Nesbitt: That would depend on the scope of the “project”. If you require services from triptic please contact us by phone or through the contactform on our website and explain in detail what you would like us to do for you.
@carrick: This type of thing is exactly what this plugin is useful for. To copy a wordpress database to a new installation (and keep the old one) you would need the “new server” approach.
Hi Onno,
Thanks for this information and plugin. I have one clarification to request, since I know enough about this stuff to get myself in trouble.
I currently have a blog located at http://www.mydomain.com/blog and would like to move it to http://www.newdomain.com at the root level. I am hosting with Godaddy and I’m able to have multiple hosting within my account. I’ve already registered the new domain and initiated the hosting request for it, I just haven’t set it up yet. Do I need to put a new installation of WordPress at the new domain name, then use one of the methods above?
I don’t have a ton of posts in the blog yet (around 50), yet I want to do the cleanest and most Google-friendly migration possible. Is it better to have hosting associated with only one domain, or is it ok to use the same hosting with the new domain name?? Thank you for any advice.
@Eric Rudd: sorry for the late reply, somehow your message hasn’t shown up on the website until now. If you follow the steps under “Moving to a new server” you should be fine. Putting the code there is one of the steps.
We started our wp site using a subdomain on our hosting server and then just now have gotten the domain from our GoDaddy account pointed at our hosting servers, so that we can begin using our real domain name. All the urls at this point are using the hosting server subdomain of course, so I think we just need to follow the change url process. I’m lost on the last step though:
“If you are using Permalinks: go to the Administration > Settings > Permalinks panel and update your Permalink structure to your .htaccess file, which should be in the same directory as the main index.php file. ”
We are using Permalinks .. but how do I update it to my .htaccess file?
Thanks for your help,
Joshua.
@Joshua McGee: I don’t think this step is necessary for you, because you’re just changing hostnames and your not really moving your blog into or from a subdirectory.
If you do need to change the permalink structure just use the button “Save Changes” or if it says your .htaccess file isn’t writable copy/paste the code displayed into your .htaccess file.
If your blog works fine without doing this, you don’t need it.
Hi Onno,
is it compatible with WP 3.x? and with WordPress Multi Site?
Thanks for this plugin and for assistance
Mac
@Mac
This plugin is compatible and tested with wordpress 3.x but not with multiple sites.
Thanks Onno,
I’ll try it soon with both installations
Will this plugin update the uri in my nextgen galleries?
Thanks,
Paul
ERROR in ezMigrate_getUrl: current script /home/vitamin/public_html could not be found in your wordpress directory /home/vitamin/public_html/blog
any thoughts on this? I have the blog files all on new domain. When I try to open the new blog site i get the above error.
Also, blogroll links are not copied? Is that in the database import?
Once migrated, can I deactivate the plugin? It made for a great switch from development domain to live one, but is now messing up my images in my Smooth Slider by adding a tag into the address that stops them displaying.
@Nik: you should be able to deactivate the plugin without any problems. There have been issues with this in the past so make sure you have the current version of the plugin.
@Matt: The standard export of wordpress does not contain blogroll information. If you also want to migrate this information you need to look at another way of dumping you datbase. For example with phpmyadmin.
I will contact you by email about the error, so we can resolve this.
@Paul: Uri’s stored or configured in plugins are not changed by this plugin, so this is also the case for nextgen galleries.
I’m stumped. Your plug-in seems to be JUST the thing I need. I cannot get it installed however.
Added this to my header.php – no problem:
<base href="/” />
Tried to make the recommended changes to wp-config.php and it puts a ton of code above my page. Also tried to activate the plugin and get this message:
Plugin could not be activated because it triggered a fatal error. in the header of your template. You can easily do this yourself by placing Fatal error: Call to undefined function ezMigrate_getFullUrl() in C:\xampp\htdocs\1910Metal.com\wp-content\plugins\ezmigrate\ezMigrate.php on line 43
Not sure where to go from here. I use the Weaver theme. Can you help?
i have the same error as Matt.
worked fine as mysite.com/wp
but i just changed settings so that mysite.com displays my wordpress
moved index & .htaccess
modified index as well
any ideas?
@John C.: This error happened when the short_open_tag php.ini directive was set to off. It is fixed in version 0.10 of the plugin.
Had a problem with ezMigrate version 0.10 and WP 3.1.3, no content was displayed for any posts:
PHP Warning: Parameter 1 to ezMigrate_show_content() expected to be a reference, value given in /path/to/wp-includes/plugin.php on line 166
however, I fixed that with:
diff –git a/blog/wp-content/plugins/ezmigrate/ezMigrate.php b/blog/wp-content/plugins/ezmigrate/ezMigrate.php
index 3efa396..ae0e7e9 100644
— a/blog/wp-content/plugins/ezmigrate/ezMigrate.php
+++ b/blog/wp-content/plugins/ezmigrate/ezMigrate.php
@@ -59,7 +59,7 @@ if (!function_exists(‘ezMigrate_getUrl’)) {
define(‘EZMIGRATE_TAG’, ‘-=-([ezMigrate_tag])-=-’);
-function ezMigrate_show_content(&$content)
+function ezMigrate_show_content($content)
{
return preg_replace(‘#(src|href)=\”‘.preg_quote(EZMIGRATE_TAG, ‘#’).’#i’, “\\1=\”".ezMigrate_getUrl(), $content);
} //function ezMigrate_the_content
Hope that helps.
@Patrick: I changed it in version 0.11
Thanks