How To Move WordPress From One Domain To Another (it’s easier than you think)

So I just read a post on WPMUDEV, which quite frankly very informative it’s called ‘A Step By Step Guide to Moving Content From One WordPress Site to Another’ it’s a great read and worth a look. Although as I read through it I thought to myself, I don’t do it like that. In fact the way I do it (I think) is a lot easier.

The scenario:

You’ve decided to make a change, perhaps you want to go from xyz.co to xyz.com and are scratching you’re head on how to do it. Perhaps the mere idea frightens you witless, there really is no need to feel that way. As I said, it really really is quite simple to do so.

No doubt you will have heard of a range of plugins and such that make the process a one click affair but stuck on which one is best? The process I use I learned off of another website which I cannot for the life of me remember (anyone who does remember the post or has seen it let me know in the comment section!!!) does not use a plugin. Yep, you heard that right, no plugins.

So Here Goes Nothing 8 Simple Steps To Move WordPress From One Domain To Another

Step One Back Up Your Website:

Back up your website. Nice and simple any WordPress compatible web host worth their salt will have a one click back up button. All you need to do is back up your files on your host of choice, either through the option to back the site up or you can use an FTP. I use FileZilla, it’s free to use and been using it longer than I can remember.

Remember we only want to back up the public_html folder contents nothing else. The root of where your WordPress install resides. Depending on the size of the folder it can take a while you will end up with a .zip file my host uses the date of the back up and the site name. Yours could be different if doing via a one click back up. If you’re downloading via FTP it will be pretty obvious what the folder is called etc.

Step Two Back Up Your SQL Database:

From your web host control panel you should be able to back up your SQL database via PHPMYADMIN. Simply navigate to it and find the database that relates to your WordPress install. If you cant remember which database it is simply navigate through your website file folders and find a file called wp-config.php. Scroll down the contents and you should see a line of code that tells you what DB the site is linking to. Make a mental note of it or jot it down.

WordPress database detail from wp-config.php

WordPress database detail from wp-config.php

Once you have that login to the PHPMYADMIN page applicable to the database in question. Click on the database and find a tab called export, export all of it and it will immediately start to download to your download folder of choice.

WordPress Database PHPMYADMIN

Hit export and wait for your database to download

Depending on the size of your database and of course internet download speeds this can take a while be patient though! Once the database has downloaded you will end up with a file called localhost.sql

Step Three Copy The WP-Config.php File

This is nice and easy, copy the wp-config.php file and save it in a secure location or ready to use on your desktop. The reason we are going to copy it is we will need to change some details in it. By copying it to a separate location if we screen it up we still have our main back up untouched replete with the original wp-config.php file. Just a precautionary measure you understand.

Step Four Your New Site Create A SQL Database

A vast majority of webhosts will allow you to create your very own SQL database, you should have the means to do this in your webhosting back end. This part again is very easy. Simply create a database with a name of your choice and a secure password or use one your webhost automatically generates. Make a note of it and keep it handy we are going to use it soon.

Step Five Import Your SQL Database Into Your New Database

From your phpMyAdmin screen (in your new database) move to the import tab and select your old database file, the localhost.sql file (if you’ve renamed it for whatever reason ensure it’s got the extension .sql on it).  See below for import screen:

Import new database

Import new database

If you’re SQL database is over 16MB (this maybe just my webhost, so cannot account for yours!) then you will need to zip it up. You have to remember to ensure that the file name must be .sql.zip otherwise it won’t work. Trust me I made this mistake before. Hit go once you have the file in question and that’s it. You’re old database has been imported into the new one!

Step Six Upload Your Old Website Via FTP

I always upload when moving to another domain via FileZilla. I prefer this method so I can see if any files have failed uploading and I can then re-cue them to upload. It’s an old fashioned way of doing things I know. Some webhosts will allow you to upload a .zip file directly into the root folder. You can do it this way if you’d like, I prefer my method as I can see it happen before me. Just in case the .zip folder upload times out and such.

Step Seven Change & Upload Your WP-config.php file

Once your site is uploaded, you just need to overwrite your existing wp-config.php file with the one you copied from before. Before we do this open it up in a text editor, I use Notepad ++. What we are looking to change is the below in the wp-config file:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘changetonewusername’);

/** MySQL database username */
define(‘DB_USER’, ‘changetonewusername’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘changetodbpassword’);

Once you have edited the above text in your wp-config.php file save it and upload it via FTP and overwrite you’re existing one. That’s it your WordPress install will now be communication to your new database. Phew that was hard? No it wasn’t was it.

Step Eight The Last Part

For the last part and in order for everything to work as it should do we need to change database entries. Presently if you have been sneaky and taken a look at your website it will not function as it should links will point back to the old site instead of being on the new domain. There’s an easy fix to this, we need the Search and Replace php script which is available to download for free from here. Quick note: I always use version 2.10 stable so use that version for this tutorial.

This really nifty php script (massive thanks to the creator) lets you search and replace text entries in your SQL database. You will need to download the script unzip it and upload the file to your server on your new domain. Change the name of the .php file to something you will remember like migration.php.

Then simply visit your new site http://xyz.com/migration.php and you will be greeted with the search and replace script see below:

Search and replace database script

Search and replace database script

All you have to do here is hit submit and the script will pre-populate your new database details see below for an example:

Search and replace database script pre-populated

Search and replace database script pre-populated

Another easy to use section, simply hit submit DB details and you will be greeted with the following screen:

Search and replace script DV details

Search and replace script DV details

I have never had any call to tick the GUID column so I usually leave it unchecked in fairness. Then it’s on to the final section in my tutorial changing the domain name. It’s squeaky bum time eeek.

Search and replace change domain

Search and replace change domain

This is where the magic happens and it’s the final step in moving your WordPress site to another domain. If you’re simply moving from xyz.co to xyz.com then this is where you would change it. This will effectively replace all mentions of xyx.co with the new one xyz.com

The same rationale could be applied if you were moving from abc.com to xyz.com you just have to remember to put in your new TLD at the end in the Replace with box.

All you need to do then is navigate to your new domain and login as you would have done on your old one using the same login details. It’s that easy. Of course you may need to do some cleaning up with changing your branding or removing instances of your old domain name if you’re moving from abc to xyz or you could use the search and replace script to do that for you. The choice is completely yours.

Summary:

I have used the above method countless times and can say that it works. As always with this type of thing sometimes things can go wrong, stop whatever else you are doing turn of or close down Twitter etc. You will need complete concentration when moving WordPress from one domain to another.

The most important thing to remember is you will always still have a back up of your original content. File it away on a USB or something off your desktop / MAC for extra safe keeping, the first time I did the above I made a mistake but through practice you will get it right. Like I said I’ve done this quite a bit now and am a dab hand at it.

Want Me To Move Your WordPress Install To Another Domain?

If you wanted me to perform the above for you and you can’t follow the above instructions I can do it for you, for a fee of course lol!

Get in touch using the form if you would like me to move your WordPress install from one domain to another.

Add Comment

+1
Pin
Tweet
Share
Share