I recently moved my blog from http://alexandrasaamuel.com/blog to http://alexandrasaamuel.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)
- 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.
- 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)
- Save your .htaccess file (and if you’re editing on your local machine rather than on the server, re-upload it).
- Load your old WordPress URL (e.g http://www.yoursite.com/blog) to make sure this worked.
- 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.