A Simple onMissingTemplate Example

2008 November 24
tags: ColdFusion
by Paul Marcotte

For the migration to Mango Blog, I wanted to preserve my previous RSS feed location (/rss.cfm). The new location is feeds/rss.cfm. With the availability of onMissingTemplate event handler for ColdFusion 8, making sure my RSS didn't break was a snap. Here's the snippet of code I added to Application.cfc.

<cffunction name="onMissingTemplate" returntype="void">
   <cfargument name="thePage" type="string" required="true">
   <cfif arguments.thePage is "/blog/rss.cfm">
      <cflocation url="/blog/feeds/rss.cfm" addtoken="false" />
   </cfif>
</cffunction>

Not the most elegant solution I've ever developed, but it keeps the RSS feed alive until I decide how I want to manage it the future...