Forum Moderators: open
<%
On Error Resume Next
Dim strReferer
strReferer = LCase(Request.ServerVariables("HTTP_REFERER"))
strURL = LCase(Request.ServerVariables("QUERY_STRING"))
blnSearchReferral = False
blnInsiteReferral = False
strError = "404"
strSite = ""
Function Custom()
If Len(strReferer)<>0 Then
'We have been referred to this page some another web page ...
If (InStr(1,strReferer,".looksmart.co") > 0) OR (InStr(1,strReferer,".ifind.freeserve") > 0) OR (InStr(1,strReferer,".ask.co") > 0) OR (InStr(1,strReferer,"google.co") > 0) OR (InStr(1,strReferer,"altavista.co") > 0) OR (InStr(1,strReferer,"msn.co") > 0) OR (InStr(1,strReferer,"hotbot.co") > 0) OR (InStr(1,strReferer,"yahoo.co") > 0) Then
'we have been referred to from a known search engine
blnSearchReferral = True
arrSite = Split(strReferer,"/")
arrParams = Split(strReferer,"?")
strSearchTerms = arrParams(1)
arrParams = Split(strSearchTerms,"&")
strSite = arrSite(2)
sQryStr = ""
' Define what search terms are in use
' Be sure to Dim the array length appropriately
Dim arrQueryStrings(4)
arrQueryStrings(0) = "q="//google, altavista, msn
arrQueryStrings(1) = "p="//yahoo
arrQueryStrings(2) = "ask="//ask jeeves
arrQueryStrings(3) = "qt="//looksmart
arrQueryStrings(4) = "query="//hotbot
Dim i,q
For i=0 To UBound(arrParams)
'loop through all the parameters in the referring page's URL
For q=0 To UBound(arrQueryStrings)
sQryStr = arrQueryStrings(q)
If (InStr(1,arrParams(i),sQryStr)) Then
'we've found a search term!
strSearchTerms2 = Split(strSearchTerms,sQryStr)
strSearchTerms = strSearchTerms2(1)
strSearchTerms = Replace(strSearchTerms,"+"," ")
End If
Next
Next
Response.Write "<p>Looking For " & strSearchTerms & "</strong>?. We're The Experts!.</p>"
End If
End If
End Function
%>
You need to add a bit to get rid of everything BUT the query. Just change that whole section to:
Dim i,q
For i=0 To UBound(arrParams)
'loop through all the parameters in the referring page's URL
For q=0 To UBound(arrQueryStrings)
sQryStr = arrQueryStrings(q)
If (InStr(1,arrParams(i),sQryStr)) Then
'we've found a search term!
strSearchTerms2 = Split(strSearchTerms,sQryStr)
strSearchTerms = strSearchTerms2(1)
strSearchTerms = Replace(strSearchTerms,"+"," ")
If (InStr(1,strSearchTerms,"&")) Then
strSearchTerms_temp = split(strSearchTerms,"&")
strSearchTerms = strSearchTerms_temp(0)
End If
End If
Hope that helps