Simple Way to Move WordPress to a Different Server Using the XML File

There are a few different ways of moving your WordPress site to a new domain. One of them involves importing and exporting your database and then using a plugin like search and replace to replace all instances of your old domain in the database with a new one. You can check out this method in detail on the moving wordpress page at WordPress.org.

In this tutorial I will be discussing another method to do this using the XML import file. Of-course it goes without saying that XML imports cannot be used to move very large websites. As an example, a site with hundreds of authors/privileged users with varied permissions or a site that has thousands of large media files. But if you have a smaller blog with a few authors, lower number of images, you can definitely give this method a try. I have used this technique to transfer many blogs without any issues. So let's see how this can be done:

Downloading the Site Files

The primary step is to download all the site files. This includes theme files, media files and the XML data file. Here are the steps to do this:

Step 1: Download XML File

Login to your wordpress dashboard, and go to Tools > Export, and click 'Download Export File'. Once downloaded, make a note of the total size of the file. Note that this XML file only contains text data and not your media attachments. We will need to download the media attachments separately.

Step 2: Edit XML File to Change URLs to the New Domain

The current XML file will contain links and image URLs that point to the old domain. Follow these steps to change this to the new domain:

1.) Open the XML file in a good text editor like Notepad++. If you don't have Notepad++, you can download it free from here.

2.) Go to Search > Replace.. or click CTRL + H to open the find and replace tool in Notepad++. Use this tool to replace all instances of oldomain.com to newdomain.com entering the following details:

Find What: old-domain-name.com
Replace With: new-domain-name.com

And then click 'Replace All'.

This will replace internal links as well as the image source location with your new domain name. So all you need to do now is upload your images to the upload folder and they will load automatically as the locations would match.

Step 3: Download the Uploads Folder

The next step is to download the uploads folder. The uploads folder contains all your uploaded images. These are the same images that exist in your WordPress Media Library (Media > Library). If you want you can use a plugin like DownML to import these files directly from the WordPress media library or use a FTP program to download these files from the server.

Note: If you are using a plugin to download the images, you might have issues with featured images being displayed as featured images use specific image ids to identify the image. Downloading and uploading the files through the wordpress media library may cause the IDs of the images to change and thereby break the featured images. You will now need to manually go to each post and update the featured image again. If this is not an issue, you can use the DownML plugin to download the images.

In this tutorial I am using the FTP method.

1.) Use a ftp software to connect to your server. If you don't know how, refer my SFTP tutorial.

2.) Once connected, double click on your public_html folder and go to 'WP-Contents'.

3.) You should be able to see the uploads folder here.

Downloading wordpress uploads folder

4.) Download this folder to your local machine.

Step 4: Download your theme files

After downloading the image files, download your main theme and child theme (if you use a child theme) files from the wp-content > themes folder.

Downloading wordpress theme folders

If you want, you can also download the theme files from within your wordpress admin area using the advanced code editor plugin as described here.

Uploading the Files

The second part of this process involves uploading these downloaded files to your new wordpress installation.

Step 5: Install WordPress for Your New Domain

Install a fresh copy of wordpress for your new domain. Once installed, go to Settings > Permalinks and change the permalink structure to match the structure of the old site. You can also delete the existing 'hello world' post and page.

Step 6: Upload Your Images/Media Files

Use a ftp software to connect to your server. And then go to public_html > wp-content and upload your 'uploads' folder here. This is the same folder that you downloaded in 'step 3'. You can also use the 'Media > Add New' to bulk upload all your images, but as mentioned above (in the note), your featured images will not work if you use this method.

Step 7: Upload Your Theme Files

Use a ftp software to upload your main theme and child theme files into your public_html > wp-content > themes folder. These are the same files we downloaded in step 4.

After uploading them theme, you can activate the theme from your admin panel.

Step 8: Import the XML file

The next step is to import the downloaded XML file. To do this,

1.) Login to the wordpress dashboard/admin panel of your new site.

2.) Go to 'Tools > Import' and select 'Wordpress'.

3.) You should now be prompted to download the 'Wordpress Importer' plugin. Click 'Install Now' to install the plugin and then click 'Activate Plugin and Run Importer'.

4.) You should now be taken to the 'Import WordPress' screen. On this screen find the line that says 'Choose a file from your computer: (Maximum size: -- MB)' and find out what the maximum size reads and compare it with your XML file's size (this is the XML file you downloaded in 'step 1').

Calculate the total size of your file by adding your XML file's size with the size of your uploads folder. If the maximum size allowed is higher than the size of your total file, you are good to go and you can skip 'Step 8'. If not you will need to increase the maximum upload file-size using your .htaccess file.

Step 9: Increasing Maximum Upload Size

The maximum upload size can be increased by making changes to the php.ini file. But if you are on a shared hosting environment, you will not have access to your php.ini file. But no worries; you should be able to do this by editing your .htaccess file as follows:

1.) FTP to your server and then go to public_html and Download your website's .htaccess file.

2.) Add the following to the end of the file and upload it back:

php_value post_max_size 64M
php_value upload_max_filesize 64M

Note: Change 64M to your required file size.

To see if your settings have taken effect, refresh your WordPress admin page or reload the WordPress importer plugin by going to Tools > Import > WordPress. The maximum upload limit should now reflect the value you set in your .htaccess file. If it shows the same old value, then it possibly did not work.

If that did not work, try creating a new .htaccess file with the above values and add it to your wp-admin folder. Make sure that the file is named .htaccess and not htaccess.txt and see if it works now. If it does not, you will need to contact your web host and ask them to temporarily increase your max upload size.

Step 10: Upload Your XML File

Once you have increased your max file size, click on 'Choose File' and load your downloaded XML file and click 'upload file and import'.

Once you click import, you will be presented with the following screen:

Wordpress importer settings

Leave the 'create new author' and 'assign posts to existing author' section as they are to import the original authors. Note that wordpress will assign a random password to these authors and change their role to subscriber. You will need to manually change their passwords and their roles back to 'author' once the import is completed.

In order to import all the images from your server, make sure to check the 'download and import file attachments' box. This will import all your images from the uploads folder into your WordPress media library. This will also ensure that all your featured images work. If you find your images sizes are not as per specifications, use the regenerate thumbnails plugin and it will sort that out.

Note: If the image upload fails, you will still be able to access your site and all your images will load, except for the featured images. You will need to manually add the featured image to your posts individually. Also, if you want, you can import your images into your media library using a plugin like the add from server.

Once this is done, your can install all your plugins and configure them as before. That's it. Your new site should now be live under your new domain. Make sure to 301 your old domain to your new domain using the .htaccess file in your old domain.

If you used this technique and it worked, please do let me know in the comments.

 
 
 
 

Comments

  1. Dan S says:

    Steps 9 and 10 are what no one else could point me to. Both hosts pointed to the other as the problem. As soon as I added the PHP lines to .htmaccess and left the fields blank in step 10, the transfer worked. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.