Skip to main content
March 28, 2008
Answered

How to strip #CGI.HTTP_REFERER# after the ? params?

  • March 28, 2008
  • 2 replies
  • 641 views
I am trying to store the #CGI.HTTP_REFERER# address into my database, which works, BUT, I don't want any characters after and including the ? in my url

for example, if I have
http://www.scooby.com/index.cfm?popo=yes&ID=22

I only want to store http://www.scooby.com/index.cfm

How can I strip that stuff after the ? before storing it?
This topic has been closed for replies.
Correct answer
Figured it out..

<cfset prefix = " http://">
<cfset full_path = "#prefix#" & "#CGI.SERVER_NAME#" & "#CGI.SCRIPT_NAME#">

2 replies

Participating Frequently
March 28, 2008
<cfset myNewLink = ReplaceNoCase(cgi.http_referer,"?"&cgi.query_string,"")>
Correct answer
March 28, 2008
Figured it out..

<cfset prefix = " http://">
<cfset full_path = "#prefix#" & "#CGI.SERVER_NAME#" & "#CGI.SCRIPT_NAME#">
Inspiring
March 28, 2008
Scooby Doobie Doo wrote:
Figured it out..
<cfset prefix = " http://">
<cfset full_path = "#prefix#" & "#CGI.SERVER_NAME#" & "#CGI.SCRIPT_NAME#">


Those are two different things. CGI.SERVER_NAME and CGI.SCRIPT_NAME refer to the current page. CGI.HTTP_REFERER is the previous referring page.

You can use list functions to extract the first part of the HTTP_REFERER string

listFirst(CGI.HTTP_REFERER, "?")