I ran into an interesting problem this morning when working on the ColdFusion Cookbook site. I was adding some protection in for URL variables. Right now when you link to a category, it looks like so:


(Minus the dev of course. ;)

This translates via URL rewriting to:


I wanted to validate that the ID was a valid one. Luckily the rewrite just ignore non-numeric numbers. So if you change 6 to apple, you get a 404. (I should probably fix that as well.) But if you change 6 to 600, you got an empty page.

So this was easy enough to handle in the controller. I added code like so:

<cfif category.getID() is "0"> <cfset arguments.event.addResult("invalid") />

Then my ModelGlue.xml had:

<result name="invalid" do="Home" redirect="yes"/>

This basically said - if an invalid result was added to the event, push em back to the home page. However - when I tested - I got an infinite redirection error in Firefox. (Hey, thank God at least Firefox recognizes that.) Turns out it was trying to go here:


Notice how it didn't remove the SES information? Turns out there is a setting in the core Model-Glue code that says what the "home" URL is. This setting is called self. You can override this in your own ModelGlue.xml, as I did here:

<setting name="self" value="/index.cfm" />

Thanks go to Doug Hughes for this idea! (And sorry Doug for forgetting your credit on the first post!)