Fixing a hole: Migrating a site structure with the Redirection plugin

Over the weekend, as previously noted, my hosting provider redirected two old versions of my blog to the new WordPress blog. When that change kicked in, it unleashed a storm of 404s as links pointing into the old site structure hit the new site structure.

There are a number of systematic changes from the old site to the new site:

  • Daily pages from my static site. These URLs look like /yyyy/mm/dd.html, and for whatever reason they weren’t redirecting to /yyyy/mm/dd/.
  • Category links from my dynamic site. This one was a mess, because there were at least two main ways of accessing my old category pages: /newsItems/department/n and /newsItems/viewDepartment$n.
  • RSS links. My old RSS link was at a different location, and apparently a lot of feed readers are still polling there.
  • Print-friendly links. Manila used to have a text-only print-friendly format; URLs with the ?print-friendly=true option were failing.
  • Differing site structures. Some of the changes were simply because I set up the new site differently.

Fortunately, most of the problems are easily solved with the help of regular expressions and the Redirection plug-in for WordPress. The redirect rules for the static date pages and the news item department pages were rewritten as follows:

  • ​/(d*)​/(d*)​/(d*).html –>/$1/$2/$3
  • ​/newsItems​/departments​/([a-zA-Z0-9]*) –> /category/$1/
  • ​/newsItems​/viewDepartment$([a-zA-Z0-9]*) –> /category/$1/

All made nice and straightforward, once you grok the syntax.

Of course, I could have used Apache’s .htaccess and these regex rules, but the big advantage of the Redirection plugin is that it counts how many times each rule is used, and links the 404 log into the rules writing engine in a very clever way. It’s very simple to find a 404, write a rule, test the rule to verify that the filter is working, and then go on your merry way.

I did have to make a decision to turn off some functionality. I don’t have mailto any more, my old sitemap is gone and not coming back, and some other odds & ends are not to return. I’ve enumerated those in my Blog Feature Graveyard.

Leave a Reply

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.