Moving WordPress: redirects

by Alex on 6/30/2005

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.

{ 2 trackbacks }

Migrate a WordPress Blog in 2,773 Steps | Postcards from the Funny Farm
5/4/2008 at 2:51 pm
Webspace of Eric Brodeur » Moving a WordPress blog to another folder
10/25/2008 at 10:23 am

{ 4 comments… read them below or add one }

Asif Alibhai 8/9/2005 at 9:00 pm

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! :D

-Asif
MacTV Videocast

alexis 11/8/2008 at 8:27 am

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

Hubbers 1/22/2009 at 4:01 am

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?

Alex 9/15/2009 at 8:26 pm

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

Leave a Comment

Previous post:

Next post: