If there are going to be only 100 URL's, and they are not going to change
often, and you have access to the server, I would suggest doing it in apache
or even IIS, as that's going to take a lot of load off your cf server...
You can generate the rules using cf from the db, write it to a file and then
have apache or iis rewrite use it... 

Russ

> -----Original Message-----
> From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 01, 2006 7:45 AM
> To: CF-Talk
> Subject: Re: HTTP 301 redirects using CFHTTP?
> 
> OK, thanks James, that was the shove in the right direction that I
> needed.  In case anyone else is looking for the same answer, here's my
> test code that works:
> 
> <cfscript>
>       qryRedirect = queryNew("oldurl,newurl","varchar,varchar");
>       tmp = queryAddRow(qryRedirect);
>       tmp =
> querySetCell(qryRedirect,"oldurl","http://localhost/test/404/nothere.html";
> );
>       tmp =
> querySetCell(qryRedirect,"newurl","http://localhost/test/404/goodurl.cfm";)
> ;
>       attemptedURL = "http://"; & CGI.server_name & CGI.script_name;
>       generatedURL = getToken(CGI.query_string, 2, ";");
> </cfscript>
> <cfquery name="checkURL" dbtype="query">
>       SELECT  newurl
>       FROM    qryRedirect
>       WHERE   oldurl = '#generatedURL#'
> </cfquery>
> <cfif checkURL.recordcount EQ 1>
>       <cfheader name="Location" value="#checkurl.newurl#">
>       <cfheader statuscode="301" statustext="Moved Permanently">
> <cfelse>
>       <cflocation url="/404.cfm">
> </cfif>
> 
> Ultimately I will have the redirects in a database which I will load
> into memory (via the application scope) for faster access.  Memory
> usage won't be an issue, there's only 100 or so URL's to redirect.  If
> anyone sees any issues with this code, please let me know.
> 
> Thanks,
> 
> Pete
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:248414
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