Dec 13, 2012

Moving wordpress site to a new address

Suppose you've built a wordpress website on www.abc.com/one, now you want to move it to one.abc.com --

Step 1. Create your subdomain and folder on your server. You don't want to destroy your original wordpress folder,  so you should use a different name, or alternatively you may rename the old folder before creating a new folder/subdomain.

Step 2. Move all files under the old folder to the new one. Be attention not to move the folder but the files under it, since you want to use one.abc.com as your root folder.

Step 3. If you're using a different database for the new location, make sure that the database is accessible. Check the configuration in "wp-config.php" to get your database name and password.



Step 4. Now you can see the website running on the new address, with all stylesheets and images still missing. To fix the problem, enter phpmyadmin or any other MySQL GUI tool to update the site url info in the database. By default you may find it in the table "wp_options".

Step 5. Now the homepage should be functioning correctly, but the dynamic page links are broken. To fix this, login the dashboard, enter "settings", and correct both "WordPress Address (URL)" and "Site Address (URL)".

Step 6. Now you've successfully moved your wordpress site! If you didn't use relative location for the links on your posts/pages, theses links may be broken after the moving work. The quickest way to fix all the links is to execute a line of SQL:

wp_posts SET post_content = REPLACE(post_content, "http://www.abc.com/one/","/");
wp_posts is the table name, while post_content is the field name. The names vary depending on how you set them up. "http://www.abc.com/one/" is your old address. In this case, we're going to use a subdomain, so I replace all the matching strings with a relative location "/", which means "root".

If you're just moving it to another folder under the domain, the command should be like:

wp_posts SET post_content = REPLACE(post_content, "http://www.abc.com/one/","/two/");

5 comments:

  1. This is great, Kero! My team had to move a wordpress site, and we could have used this information to make it much easier. Thanks for posting.

    ReplyDelete
    Replies
    1. Glad this post can help you. Ask me anytime you have problem with it ;)

      Delete
  2. Ed actually forgot to teach us about this haha! thx kero, now we r more completed

    ReplyDelete
    Replies
    1. Yes Ed asked me to email this to him, and then he must have forgotten...

      Delete
  3. Hey thanks Kero ... this is exactly what I need when it comes time to move my blog to it's proper domain names.

    Bookmarked

    ReplyDelete

Hi, I'm Kero, a web developer.