Tech Stuff

Tips for Using the WordPress Redirect Plugin

Redirect is a handy plugin to have available for the multi-site network I manage. But the documentation is a little thin. Here’s a few quick tips so that you don’t have to spend as much time as I did.

I was consolidating three blogs into one, exporting the posts from the old and importing them into the new. The categories, tags, authors and archives were going to remain more or less unchanged, only the base URL and/or subdirectory was going to be different.

The regular-expression reader falls down when confronted with ‘/’ in the source URL. You’re using pretty permalinks, right? So does your new blog? It’s better IMHO to redirect things where you can to the new site where they match up. So your URLs are going to look something like:

http://my.blog.com/oldblog/2011/10/thispost/

You could go ahead and escape all the slash characters, “\/”, but you still end up with a hard-to-read regex (I know, I know, aren’t they all) like “/this(\/.*)?”. Even that’s not going to work because you don’t know how many you have.

I found it simpler (thanks, sroot) to do a cascade of rules. Looking through my source blog, it didn’t seem that there were going to be any more than five groupings, so I did one for each.
redirect

Be sure to check the RegEx box for the ones where it’s appropriate.

On the other hand, a different blog going to a different URL. The original used query strings, and you have to escape the “?” at the beginning.
redirect2

Or you end up with redirects that go like this:
redirect3The /? at the beginning doesn’t work very well.

After you get it working right, be sure to go into the Options panel and clear the Log Redirects box. I found that in an afternoon, my redirects log table filled up with 17,000 entries, and that can’t go on forever.

Tom
Tom McGee has been building web sites since 1995, and blogging here since 2006. Currently a senior developer at Seton Hall University, he's also a freelance web programmer and musician. Contact him if you have the need for a blog, web site, redesign or custom programming!

Leave a Reply

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