Put the code below into a .cfm page, then point the IIS 404 and CFM missing
template to point to this page when a page is not found. Once you get the
missing page (404) errors pointed the page that contains this code this
should work as is, except for the redirect conditions. You'll need to code
in the conditions to so as you'd like.
(FYI - The page does a lot more that this abbreviated version, so you won't
need all the vars below. I just yanked this from one of my sites. You can
play it out to your needs).
Hope this helps,
Robert
<cfsilent>
<cfset rootip="http:/;/myrootip.com"> <!--- SET YOUR ROOT IP HERE
--->
<cfparam name="strTargetUrl" default="">
<cfparam name="strTargetQueryParams" default="">
<cfparam name="strTargetDirectory" default="">
<cfparam name="strTargetScriptName" default="">
<cfset strTargetUrl = LCase(REReplace(CGI.query_string,
"404;|:80|www\.","","ALL")) />
<cfset strTargetUrl = Replace(strTargetUrl,rootip,"","ONE") />
<cfif Find( "?", strTargetUrl )>
<cfset strTargetQueryParams =
ListRest(strTargetUrl,"?") />
<cfset strTargetUrl = ListGetAt( strTargetUrl, 1,
"?" ) />
<cfelse>
<cfset strTargetQueryParams = "" />
</cfif>
<cfset strTargetUrl =
REReplace(strTargetUrl,"[\\/]+","/","ALL") />
<cfset strTargetUrl =
REReplace(strTargetUrl,"^[\\/]+|[\\/]+$","","ALL") />
<cfif REFind( "\.[\w]+$", strTargetUrl )>
<cfset strTargetDirectory =
REReplace(GetDirectoryFromPath( strTargetUrl ), "[\\/]+$","","ONE") />
<cfset strTargetScriptName = strTargetUrl />
<cfelse>
<cfset strTargetDirectory = strTargetUrl />
<cfset strTargetScriptName = strTargetUrl />
</cfif>
<!--- conditions for redirect --->
<cfif Find("badpage1.cfm", strTargetUrl )> <!--- USE THIS FORMAT TO
LOOK FOR A SPECIFIC PAGE, CFELSE IF UNTIL YOU ARE OUT OF SPECIFIC PAGES --->
<cflocation url="#rootip#/newpage2.cfm" addtoken="no">
<cfelseif Find("badpage1.cfm", strTargetUrl )> <!--- NEXT PAGE TO
REDIRECT --->
<cflocation url="#rootip#/newpage2.cfm" addtoken="no">
<cfelseif Find("baddirectory1", strTargetDirectory )> <!--- USE THIS
FORMAT FOR LOOKING FOR A DIRECTORY NAME IN URL STRING --->
<cflocation url="#rootip#/newpage3.cfm" addtoken="no">
<cfelse>
<cflocation url="#rootip#" addtoken="no"> <!--- GO TO ROOT
JUST IN CASE, OR CODE SOMETHING ELSE HERE, OR DISPLAY A 404 MESSAGE HERE
--->
</cfif>
</cfsilent>
Robert B. Harrison
Director of Interactive Services
Austin & Williams
125 Kennedy Drive, Suite 100
Hauppauge NY 11788
P : 631.231.6600 Ext. 119
F : 631.434.7022
http://www.austin-williams.com
Great advertising can't be either/or. It must be &.
Plug in to our blog: A&W Unplugged
http://www.austin-williams.com/unplugged
__________ Information from ESET Smart Security, version of virus signature
database 5167 (20100602) __________
The message was checked by ESET Smart Security.
http://www.eset.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334236
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm