WLAN Book

How to Move WordPress With htaccess and 301 Redirect

wordpress-logo.pngMy blog location was http://www.wlanbook.com/blog/ and I decided to move the blog to domain root directory (http://www.wlanbook.com).

Outlined below are the steps I took to move the site that results in a graceful and beautiful move that is seamless to users and search engines.

  1. Make backup of WordPress database and blog directory.
  2. Copy core directory files and subdirectories to root directory. I have a Linux account with 1and1 and they provide full shell access so I was able to use “cp -r /blog/ ../” to copy contents of blog directory to new location.
  3. Next I logged into WordPress admin console navigated to Options -> General and modified WordPress address (URL) and Blog address (URL) to reflect new location (http://www.wlanbook.com).
  4. I then rebuilt all the “permalinks” in the admin console using Options -> General -> Permalinks and “Update Permalink Structure”.
  5. Check to make sure all images are working. Most likely your images are referencing the old URL and per the WordPress folks you will need to “change the path to the images on every post directly [or] on your SQL database”. You can also copy images to old directory path or create a directory symbolic link until you can make manual changes.
  6. I then made sure the new address worked before deleting wordpress files in /blog/ directory (You should have backup if you followed step 1!).

Now that the site has been moved and is working as desired several other housekeeping issues need to be addressed.

  1. Update statistic tracking tools (Google Analytics, MyBlogLog, Google Webmaster, etc)
  2. Update user profile(s) including WordPress user profile with new address.
  3. Create a htaccess file in old WordPress directory (/blog/ for me) with 301 redirects to automatically redirect users to new address. More importantly this will update information indexed by search engines such as Google.Outlined below is htaccess file with 301 redirect info. This file is placed in the old directory only and will redirect all users and search engines to new site.
    RewriteEngine On
    
    RewriteBase /blog/
    
    RewriteRule ^(.*)$ http://www.wlanbook.com/$1 [L,R=301]

    Now any old URL in Google will get redirected to new location.

    Graceful and Beautilful!

WordPress also has a guide to moving your site with good information.

Share and Enjoy:
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon
  • Facebook
  • Sphinn
  • TwitThis
  • LinkedIn
Related Posts:

Related posts brought to you by Yet Another Related Posts Plugin.

If you liked this post, subscribe using below

WLAN Book RSS Feed

RSS Email WLAN Book by Email

.

Filed under: How To Guides

3 Responses to “How to Move WordPress With htaccess and 301 Redirect”

  1. Oh man you saved me!!! Thanks so much for this post it bailed me out of a big mess with another blog site that I have been setting up. Thanks again,

    Tyler

  2. Hi there. What if I would like to move my blog into the root domain without moving the blog directory. So the wordpress files stays in /blog/ directory, do you know what I should put in the .htaccess inside /blog/ directory? Thank you.

  3. Hi, I think I have solved my problem. Thanks anyways for a very informative guide.

Leave a Reply