The great spring cleanup escapade is about wrapped up now.
The one sticking point had been dealing with legacy entries in the archives directory. I didn't really want a several hundred line .htaccess file. A recent discussion on Ben Hammersley's site: Calling the Apache htaccess masters provided the missing clue.
Using RewriteMap and a small template, I was able to force the mapping for the legacy posts to the new location. The MT template (used to generate a file called archive-link.map) looks like this:
<MTArchiveList> <MTEntries><$MTEntryID pad="1"$>.html /blog/<$MTArchiveDate \ format="%Y/%m/%d/"$><$MTEntryTitle dirify="1"$>.html</MTEntries> </MTArchiveList>
The rewrite rules (which I had to put in httpd.conf instead of an .htaccess file for some reason) look like so:
# remapping archive posts to new locations...
RewriteEngine on
RewriteMap old-post-mapping txt:/full/unix/path/to/archive-link.map
RewriteRule ^/blog/archives/(.*)$ ${old-post-mapping:$1} [R=301,L]
While I was at it, I moved the categories, daily and monthly archives to where I meant to place them the first time around (not down in the archives) and added some new redirects to fix that part of the mess.
Hopefully, that covers it and I haven't broken anything in the process (something might have been missed, but I hit a lot of URL's making sure that the redirects all worked). We shall see!
Posted by Dave at June 12, 2004 06:36 PM