I never got into any sort of specifics in that thread.  Here are some:

First of all, I take query output and use that to come up with a
filename.  For the sake of argument I'll make that url

dodge_magnum_headers_1234567.cfm

where the first three elements are keywords pulled from the db record and
the last item is the record pk.  Its worth noting I actually go thru a fair
bit of washing and scrubbing to ensure the keywords pulled from the db are
urlsafe and to my liking.  No apostrophe's; replace dashes with
underscores.  That sort of thing.  I also preface the url with a folder name
that also contains keywords, but which I know doesn't exist (although
strictly speaking, it could if I wanted to add a bit into my 404
processing).  So the full pseudo url winds up looking like this:

/discounted/dodge_magnum_headers_1234567.cfm

The built link is then diisplayed on the output page.  When the link is
called, it doesn't exist so it hits the 404 template.  That template starts
out like this:

<cfset is404="true">
<cfif FindNoCase("discounted/",cgi.script_name,"1")>
   <cfset is404="false">
   <cfset url.pk=ListLast(ListFirst(ListLast(cgi.Script_Name,"/"),"."),"_")>
   <cfset thisURL="http://foo.com/productdetail.cfm?PK=#url.pk#";>
</cfif>

Basically I started out with a page that was dynamic on a web site (and
still is via their search interface), and now I am set to dummy up a way to
access that page as if I was hitting it the old fashiopned way.  The
template continues (and here's where it gets crazy... on the surface):

<cfif is404>
   <!---
   didn't trip the stuff above so must be a real 404.
   Dump them to the site's home page
   --->
   <cfset variables.GoPage="http://"; & CGI.SERVER_NAME>
   <cflocation url="#variables.GoPage#" addtoken="No">
<cfelse>
   <!---
   we found something. get the page
   --->
   <cfhttp
      url="#thisURL#"
      method="GET"
      timeout="20"
      resolveurl="YES"
      port="80">
   </cfhttp>
   <!---
   display what we got
   --->
   <cfoutput>#cfhttp.FileContent#</cfoutput>
   <!---
   kill the waaabbit
   --->
   <cfabort>
</cfif>

Now, before you take after me for losing my mind using cfhttp to do this,
note what we found in that other thread:  That a cfinclude was found to not
work for some annoying reason when used in the 404 handler; under wide
variety of tests.  PLUS I found that using cfhttp to call stuff on your own
server was proving to be a negligible draw.  Something like 10ms (I have
SeeFusion hooked up to the server and monitored pretty closely).  The site I
implemented this on gets a few tens of thousands of hits daily like this so
its not quite a mom-and-pop web site.

You can stack multiple cfif's up in the 404 handler so you can apply this
technique to various sites.  Not something I would do for 100 diffferent
conditions but if thats an issue you could surely figure out a way to use a
switch if you had to.

HtH,

--
--mattRobertson--
Janitor, MSB Web Systems
mysecretbase.com


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:228608
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to