| Wednesday November 26th 2014

Feedburner

Subscribe by email:

We promise not to spam/sell you.


Search Amazon deals:

HOWTO: Move a WordPress blog to another domain. The complete guide and best practices


Wordpress logoAs you may have noticed, this site has been renamed from twinturbo.org to landofthefreeish.com. Below is how we made the transition from old to new and how to properly move a WordPress blog without breaking image links or your precious seo backlinks.

  1. Make a backup of your database. I simply logged into Phpmyadmin and made a copy of the old-domain’s database and named the copy something different for the new-domain. You may also use mysqldump from the CLI. If you still aren’t comfortable enough to do it, check out this topic at WordPress.org.
  2. Create a user to access that new database and give it all privileges on that database alone (no need to use mysql root, and your user doesnt need access to other databases for security’s sake.) I use a password generator to generate database passwords as a completely random password like “x5(kv2#56m,swLs!” is perfect for a databse as you only need to cut and paste it once. Remember the username and password assigned for use in step 4.
  3. Go to your mysql database, be either logging into to mysql from CLI or in Phpmyadmin: click on SQL tab, paste it the commands below, and hit execute. That will update all your WordPress options and urls. Remember to execute these commands on the new domain’s database as that is what you will soon be using.
    UPDATE wp_options SET option_value = replace(option_value, 'http://old.com', 'http://new.com') WHERE option_name = 'home' OR option_name = 'siteurl';
    Now you need to update your posts and pages urls.
    UPDATE wp_posts SET guid = replace(guid, 'http://old.com','http://new.com');
    As a final step, you’ll want to update absolute urls to your old domain that you probably placed within your posts.
    UPDATE wp_posts SET post_content = replace(post_content, 'http://old.com', 'http://new.com');
  4. Edit your wp-config.php file from the root of your blog directory structure. You may either download the file and edit it offline or just use SSH and edit it with vi, nano, pico, et cetera. You want to change the database name, username, and password to the new info we created in step 2.
  5. Either rename your old directory name to the new domain name, or just move all the files in it (e.g. your blog, et cetera) to the new directory for apache to find it.
  6. In the old-domain’s directory (which should be empty now), create an .htaccess file and populate it with the following:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^old.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.old.com$
    RewriteRule ^/?(.*)$ "http\:\/\/new\.com\/$1" [R=301,L]

Now you should be able to log in to your admin panel afrom the new domain and crete content as usual. The .htaccesss in the last step will forward any backlinks from the old-domain to the new-domain.

Note: If you want to move your blog to a folder or subdomain of your new domain, let’s say new.com/blog or blog.new.com, the .htaccess above is not for you.

Redirecting to a folder.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^/?(.*)$ "http\:\/\/www\.new\.com\/your-folder\/$1" [R=301,L]

Redirecting to a subdomain.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^/?(.*)$ "http\:\/\/sub.new\.com\/$1" [R=301,L]

Related Posts: On this day...

Reader Feedback

One Response to “HOWTO: Move a WordPress blog to another domain. The complete guide and best practices”

  1. Wes says:

    I think registry cleaner is helpful sometimes

Leave a Reply

You must be logged in to post a comment.