From: cfproponent on
I've just spent a couple of days trying different ideas for using the WURFL XML
document with CF, for detecting mobile devices. WURFL (Wireless Universal
Resource
File) is a project organized by Luca Passani, which collects information on
mobile
devices and organizes the info in an XML document format. More info on WURFL
is at
wurfl.sourceforge.net.

The first thing is to download the WURFL document file from the website given
above.
I setup a scheduled weekly download.

The WURFL document is about 7mb so you want to get it into an application
variable for quicker access.
Insert the first block of attached code into your application.cfm file. Modify
the file path to where you downloaded the WURFL file.

Now insert the second block of code into a file that you will cfinclude in any
page you want
redirected to the mobile website. Modify the web site address.

When a desktop browser is detected, the array (wurfl2) will be empty, so no
redirect occurs.
If a mobile browser is detected, the array will contain all of the pertinent
infomation that the WURFL document has regading the detected browser, if you
want to use it to customize your output.

<cfif NOT IsDefined("application.wurfl")>
<cffile action="read" file="file_path\wurfl.xml" variable="xmldoc">
<cfset application.wurfl = "#XmlParse(xmldoc)#">
</cfif>





<cfset wurfl2 = #XmlSearch(application.wurfl,
"/wurfl/devices/device[@user_agent = '#cgi.HTTP_USER_AGENT#']")#>
<cfset arrstat = #ArrayIsEmpty("#wurfl2#")#>
<cfif #arrstat# is "NO">
<cflocation url="http://mobile.website.com">
</cfif>