As you might have noticed, there is a new domain name for this blog. Now the domain is http://redoem.com It is easier to remember and shorter than the previous one (http://blog.zasekoj.com).

The whole process took approximately 45 minutes, but yours could vary depending on the amount of posts, comments, images etc that you have.

NOTE: this is not for blogs hosted on wordpress.com. For them many of the steps will be different, but you can try and adapt the following.

OK, enough chit-chat, let’s get to work. First of all, of course, you need to buy a new domain name (I am using DreamHost – you can register as well for hosting and use coupon REDOEM30 to get 1 extra FREE lifetime domain registration and $30 off your total amount!).

  1. Create a new user in your panel (if the hosting does not do it automatically) which will have FTP access to your domain name.
  2. Remove all the junk that you do not need like spam comments pending, drafts you are not planning to use, themes that you don’t need etc. This takes additional space and there is no need to transfer it across different databases.
  3. Disable all the WordPress plugins and empty cache if you are using caching plugin
  4. Export your database
    • Login to your MySQL server (phpMyAdmin) and click on the Export tab
    • Select your database on the left of the screen (do not select the Information_Scheme database)
    • All of the settings by default should be OK, unless you are advanced user and you know what you are doing and what else you might need
    • Go to the bottom of the page and click the check box that says Save as file
    • Enter a template for your filename (the default is OK)
    • Leave the Compression set to None. It will cut few steps later
    • Click the Go button on the bottom-right and save the file to your disk
  5. Open the saved export file in a text editor which supports Find and Replace (like Notepad++, TextMate, GEdit etc)
  6. Find and replace all of the instances where your old domain name is used. NOTE: start with the longest string, for example db.olddomain.com would be replaced with db.newdomain.com, then go on to the lower lever by replacing olddomain.com to newdomain.com, and last just the domain name from olddomain to newdomain. Please be careful with this last one because it could change some of the things that you don’t want to be changed. I recommend to check which instances are they and either replace them one by one where needed or use extra filters. For example when I was doing this last bit I used /home/olddomain/ to /home/newdomain/ because that worked for me, see if such options will work for you too.
  7. If you want to change the database name, at the top of the file there should be a statement like “CREATE DATABASE namehere ….” change the name to whatever you want. Please note that later you will need this name.
  8. Save the file
  9. Login to your new MySQL Server (phpMyAdmin) for the new domain.
  10. Click Import and select the file that you modified. Click OK
  11. When the import is complete, you will receive a message stating that, if there are errors you will be informed as well. Now we will assume that it was successful.
  12. Login via (S)FTP to your olddomain where the WordPress installation is currently located
  13. Copy all the files (the wp-include, wp-content and wp-admin folders as well) from olddomain.com to your local disk (recommended) or directly to the newdomain (usually via SSH)
  14. Open the file wp-config.php in a text editor and modify the following fields:
    • define(‘DB_NAME’, ‘newdatabase’);  — this is the name from step 7
    • define(‘DB_USER’, ‘newdatabaseuser’);   — this is the user that you use to connect to the database/phpMyAdmin
    • define(‘DB_PASSWORD’, ‘newdbpass’);  — this is the password that you use to connect to the database/phpMyAdmin
    • define(‘DB_HOST’, ‘db.newdomain.com’);  — this is the hostname for the new database
  15. Transfer all the files to the newdomain.com folder
  16. Try to open the newdomain.com site — it should open successfully
  17. Reactivate all the plugins that you had previously, or the ones that you want one. Some of them might need to be re-configured to work on the new domain (SEO, Google Sitemap etc)
  18. Change any custom code that you have, like Google Analytics, Adwords etc
  19. Create a new file called .htaccess(note the dot at the beginning and no extension) for permanent redirect from the old site to the new site. This is important so that you don’t lose any traffic. However if you are losing the olddomain.com you cannot do this. Enter the following in it:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://newdomain.com/$1 [R=301,L]
  20. Place the newly created file .htaccess inside the olddomain.com directory
  21. Remove all the files inside the olddomain.com directory (EXCEPT the .htaccess file that you added in step 20)
  22. Try the old site and see if the redirect works properly

Well, that was it. After all of these steps your WordPress installation should be moved to the new domain name and everything should stay the same. The redirect is very important (step 19) so make sure you keep your old domain for at least several more months after the move so that all the old traffic is redirected successfully. You can omit this step if you have a new site with very few visits, but then again I guess you can just create a new WordPress installation and do not perform the above steps 🙂

Enjoy and let me know in the comments if you have any problems.