Ask Ben: Redirecting Users To A Random Page

<!--- Create an array of URLs to which we are redirecting. --->
<cfset arrPages = ArrayNew( 1 ) />
 
<!--- Add the temporary pages to the array. --->
<cfset ArrayAppend( arrPages, "./temp/one.cfm" ) />
<cfset ArrayAppend( arrPages, "./temp/two.cfm" ) />
<cfset ArrayAppend( arrPages, "./temp/three.cfm" ) />
<cfset ArrayAppend( arrPages, "./temp/four.cfm" ) />
 
 
<!---
	Because we are using this as a "Temporary Page", we can
	use a standard CFLOcation tag. If we wanted this to be more
	permanent, I would recomment using the CFHeader tag to
	provide the propery status code (or CFLocation if you are
	using CF8).
 
	Let ColdFusion select a random page using RandRange() and the
	size of the pages array.
--->
<cflocation
	url="#arrPages[ RandRange( 1, ArrayLen( arrPages ) ) ]#"
	addtoken="false"
	/>

For Cut-and-Paste