Skip to main content
Inspiring
November 15, 2007
Question

Find domain in referer

  • November 15, 2007
  • 5 replies
  • 528 views
The following code finds and outputs the keywords from a cgi.referer What do I need to do to get it to look for a domain in the referrer value passed (i.e. yahoo.com or google.com or hotbot.com etc.) and to set this value in a variable as happens with searchPhrase in the code? Thank you for any pointers

<cfif len(cgi.HTTP_REFERER)>
<cfif find("?", cgi.HTTP_REFERER)>
<cfset paramList = "q,p,terms,search,query,qkw">
<cfset strStart = find("?", cgi.HTTP_REFERER)>
<cfset referer_queryString =
right(cgi.http_referer,len(cgi.HTTP_REFERER)-strStart)>
<cfset referer_url = left(cgi.HTTP_REFERER,(strStart-1))>
<cfloop list="#referer_queryString#" delimiters="&" index="i">
<cfif listfind(paramList,listfirst(i,"="))>
<cfset variables.searchPhrase = listlast(i,"=")>
</cfif>
</cfloop>
</cfif>
</cfif>
<cfif isdefined("variables.searchPhrase")>
<cfoutput>#variables.searchPhrase#</cfoutput>
</cfif>
This topic has been closed for replies.

5 replies

November 15, 2007
The value of the HTTP_REFERER is a slash-delimited list. So http://proto.foo.com/bar/ is a list with three elements: http, proto.foo.com and bar.
Inspiring
November 15, 2007
Right so if I do list find then I should be able to find the value? I`ll try with that
Inspiring
November 25, 2007
listGetAt()
is what i need suppoosedly so I ´ll look at that
Inspiring
November 15, 2007
Hi Daverms- that doesn`t seem to be working anymore.

Going back to the original code can I try to replicate this time searching for something.com as a solution? What is the code to look for something.com? TIA
Inspiring
November 15, 2007
Hi,

Try something like this,

Inspiring
November 15, 2007
Inspiring
November 15, 2007
which udf the cflib getgoolekeywords udf?
Inspiring
November 15, 2007
Hi,

Try this UDF