Moving WordPress: redirects

In: , , , ,

I recently moved my blog from http://www.alexandrasamuel.com/blog to http://www.alexandrasamuel.com. That involved not only moving my actual WordPress program files but also figuring out how to redirect visitors following outdated links to my old content.

Today the ever-helpful Boris Mann pointed out that the way I had originally set up redirects totally messed up my RSS feeds and search engine results. He pointed me towards the beauty of 301 redirects, which do a nice job of preserving past and current search results.

So for the record, here is THE simple how-to for handling redirects after moving a WordPress blog (it’s been a couple of weeks since my original move so I can’t remember the steps that were required to move the WordPress install itself, but I think there’s info out there on that.) I’m basing my example URLs here on what I just went through, i.e. moving WordPress from a subdirectory (www.yoursite.com/blog) to the root directory (www.yoursite.com)

  1. Open your .htaccess file (in the directory that houses your newly moved WordPress files) and edit in either your host’s file manager interface or by downloading to your local machine.
  2. Insert a line at the top that reads:
    redirect 301 /blog/ http://www.yoursite.com/
    Make sure to insert the opening and trailing / at the beginning and end of the originating path (e.g. /blog/) and to insert the trailing / at the end of the destination path (e.g. http://www.yoursite.com)
  3. Save your .htaccess file (and if you’re editing on your local machine rather than on the server, re-upload it).
  4. Load your old WordPress URL (e.g http://www.yoursite.com/blog) to make sure this worked.
  5. Enjoy the redirecting goodness.

I admit it’s a bit counterintuitive that the path you’re moving from needs to be input as just a path (e.g. /blog/ with no http://URL before it) while the path you’re moving to needs to be input as the full URL (e.g. http://www.yoursite.com). Maybe it’s just my server? But the Internet is a capricious and mysterious creature so I don’t ask, I simply do what works.

Thanks to the helpful article on 301 redirects at Taming the Beast for pointing me towards the right syntax.

8 Comments on this site

  1. Asif Alibhai

    Alexandra,

    YOU’RE A GODDESS! I honestly owe you my life..

    I’m right in the middle of moving our website (www.watchmactv.com) to a new domain..and I’ve been racking my brain with .htaccess to get redirects working properly.

    Thank you so much! 😀

    -Asif
    MacTV Videocast

  2. Asif Alibhai

    Alexandra,

    YOU’RE A GODDESS! I honestly owe you my life..

    I’m right in the middle of moving our website (www.watchmactv.com) to a new domain..and I’ve been racking my brain with .htaccess to get redirects working properly.

    Thank you so much! 😀

    -Asif
    MacTV Videocast

  3. alexis

    Thank you so much for sharing this! I was having so much trouble with this and you’ve really saved me here.

    Thank you thank you

  4. alexis

    Thank you so much for sharing this! I was having so much trouble with this and you’ve really saved me here.

    Thank you thank you

  5. Hubbers

    I have done this and it doesn’t work. Obviously I have done something different with my move to what you have done, but what?

    http://www.hubbers.com/blog/

    Could it be that i am on IIS?

  6. Hubbers

    I have done this and it doesn’t work. Obviously I have done something different with my move to what you have done, but what?

    http://www.hubbers.com/blog/

    Could it be that i am on IIS?

  7. Alex

    Hubbers, I wonder if this is due to changes in subsequent versions of WordPress? Anyone else care to weigh in?

  8. Alex

    Hubbers, I wonder if this is due to changes in subsequent versions of WordPress? Anyone else care to weigh in?

Trackbacks/Pingbacks

  1. Migrate a WordPress Blog in 2,773 Steps | Postcards from the Funny Farm - [...] I also went through several tutorials and this one was the best: alexandrasamuel.com/20050630/moving-wordpress-redi... [...]
  2. Webspace of Eric Brodeur » Moving a WordPress blog to another folder - [...] use Alexandra’s technique to modify your .htaccess file and all of your old permalinks will 301 [...]

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This