Index Template to Create Redirect list for .htaccess

I decided to change the structure of the /articles/ site slightly, to remove the /archives/ path from the URL and to change the filename from the article number to a munged form of the title.

As there weren't many articles, I could easily manually create a redirect list for my .htaccess file, but I wanted to see if I could use a MovableType Index Template to do so.

Below is the template I created, I use Redirect instead of RedirectMatch or the RewriteEngine because there isn't a regular pattern to rewrite the URLs to (I can't use a map file on the hosting platform I'm on).


<$MTArchiveList archive_type="Individual"$>
<MTEntries>
Redirect permanent /articles/archives/<$MTEntryDate format="%Y/%m"$>/<$MTEntryID pad="1"$>.php <$MTBlogURL><$MTEntryDate format="%Y/%m"$>/<$MTArchiveTitle dirify="1"$></MTEntries>
</MTArchiveList>

This writes out to /articles/archives/.htaccess.

Note: There appears to be a bug in MTArchiveTitle in the archive file template context, it appears to resolve to an empty string. Switching to MTEntryTitle seemed to work.

Update: 16 June 2004

I realized I missed redirects for the category archives I had, I've added those with the changes in bold below:

<$MTArchiveList archive_type="Individual"$>
<MTEntries>
Redirect permanent /articles/archives/<$MTEntryDate format="%Y/%m"$>/<$MTEntryID pad="1"$>.php
<$MTBlogURL><$MTEntryDate format="%Y/%m"$>/<$MTArchiveTitle dirify="1"$></MTEntries>
</MTArchiveList>
<$MTArchiveList archive_type="Category"$>
Redirect permanent /articles/archives/cat_<$MTCategoryLabel dirify="1"$>.php <$MTCategoryArchiveLink$>
</MTArchiveList>

«On this date in 1990 (alternately: Do the math) | Main |Plug: Bloglines »

:
:

Enter your email address:

Delivered by FeedBurner