Redirection via WordPress Plugin

When I was moving my site to a new host I figured I’d have broken links, especially since I was making a change to the structure. So I had installed the Redirection plugin by John Godley at Urban Giraffe. As part of it’s functionality it tracks 404 erros and allows for the easy creation of redirects for those URLs. It doesn’t require .htaccess to make the changes.

While I hadn’t intended to use it to handle redirection for the /blog directory change, I decided to give it a try once I saw the errors from the Google web crawler since it was easier than figuring out the .htaccess commands. Plus, at the time I had access to my blog but not ftp access to the server. The plugin supports regex redirects and the website gave an example of exactly what I needed. Google hasn’t crawled my site again so it remains to be seen if it’s a true fix to the problem. (In the past, typing old /blog URLs manually were properly redirected so the fact they still work doesn’t actually prove the problem is fixed, but all signs are positive.)

But I did find another problem caused by the way I imported the postings/comments/categories from the old site rather than doing a database backup/restore. On the old site I had changed some category, posting and page names without changing their slugs. When I imported them into the new site it looks like new slugs for the permalinks were generated based on the current info (the slugs used for permalinks are based on title and are generated when the first save is done, even if it’s a draft). They began showing up in the 404 error log files for the Redirection plugin. It was simple enough to create the redirects based on these logs. In the case of category changes I could create regex redirects. The plugin logs the bad URL as a link so it was easy enough to verify it was bad and then verify the redirect worked.

The plugin has some other nice little features:

  • For each configured redirection it keeps track of the number of redirections performed and the last date one was done.
  • I’ve only used simple redirection but it will also redirect in other ways – to random URL, based on referrer, based on login status and to one of several URLs
  • I’ve only used 301 and 302 redirects but it also does 307, 404 and pass-through redirects

An updated was released yesterday (which I haven’t had a chance to download) which has some nice usability enhancements (a search and a minor tweak to jump down to the new redirect fields when clicking the button to create a new redirect from a logged error. I haven’t had enough redirects to notice the need for these yet but they’ll certainly be appreciated if the list grows.

I had actually avoided this plugin (actually any redirect plugin at first) because I figured it would be better to manage through .htaccess. But further research shows that WordPress creates a default redirect that puts all URLs through WordPress so there doesn’t seem to be any benefit to using .htaccess for the redirects. It just seems easier to use the plugin, with no down-side, so I’ll probably be using it even more, especially if I do any major redesigns.