I have a non-database demo that I wrote that is a watered down version
of what I do.... It a bit much to take in, but I tried to comment it up
wazoo:

http://www.bennadel.com/blog/286-Handling-404-Errors-in-ColdFusion-via-I
IS-Throwing-404-.htm 

.... Which is actually ...

http://bennadel.com/index.cfm?dax=blog:286.view


......................
Ben Nadel
Certified Advanced ColdFusion Developer
www.bennadel.com
 

-----Original Message-----
From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 28, 2006 10:37 PM
To: CF-Talk
Subject: Re: Handling "Marketing URLs"

Here's the 404 redirector code that I developed for a couple of my
sites:

<!---
        404 Redirector
        Query redirects table //for all active values, put in server
scope.
        //Uses QoQ to get values,
         - if value is in the database, do an HTTP 301 (Moved
Permanently) redirect.
         - if value is not in the database, do an HTTP 307 (Temporary
Redirect)
         //- if value is not in the database, insert it
         //- if value is in the database but doesn't have a goodurl set,
increment the count
         + Requires datasource "redirects"
--->
<cfscript>
        attemptedURL = "http://"; & CGI.server_name & CGI.script_name;
        generatedURL = getToken(CGI.query_string, 2, ";");
        if (len(trim(generatedURL)) EQ 0) {
                generatedURL = attemptedURL;
        }
        if (findNoCase(":80", generatedurl) NEQ 0) {
                generatedurl = replacenocase(generatedurl, ":80", "");
        }
</cfscript>
<cfquery name="qryRedirect" datasource="redirects">
        SELECT          R.goodURL
        FROM            tblRedirects R
        WHERE           R.badURL = '#generatedURL#' AND
                                ((R.goodurl IS NOT NULL) OR
                                (R.goodurl != ''))
</cfquery>
<cfif qryRedirect.recordcount GT 0>
        <cfheader name="Location" value="#qryRedirect.goodurl#">
        <cfheader statuscode="301" statustext="Moved Permanently">
        <cfabort>
<cfelse>
        <cfheader name="Location" value="/resources/sitemap.cfm">
        <cfheader statuscode="307" statustext="Temporary Redirect">
        <cfabort>
</cfif>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254728
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to