1
votes

I am storing a google review URL in my database as:

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair%2Bbrick%2Bnj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd=0x89c18348735c2907:0x59aa614832a36b22,3,

And then in my application I set that URL to a variable and I redirect the user to that URL using cflocation.

<cfquery name="geturl" datasource="#datasource#">
select (residential_ReviewURL) as redirectURL
from subscribers
</cfquery>

<!--- Redirect to main html redirect page --->
<cfoutput>
<cflocation url="#getURL.redirectURL#">
</cfoutput>

However the URL gets changed at some point because I think that Coldfusion doesn't like the characters in the URL and it replaces them with % or removes them. Therefore when the user hits the google page, the page doesn't process as it should.

Here is how the URL looks after the redirect:

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair%2Bbrick%2Bnj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd%3D0x89c18348735c2907%3A0x59aa614832a36b22%2C3%2C

How can I stop ColdFusion from changing the URL and keep id exactly as how it is stored in the database?

UPDATE

So I found that URLdecode will preserve the string. Here is what I have.

#urlDecode(getURL.redirectURL)#

The output is as follows

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair+brick+nj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd=0x89c18348735c2907:0x59aa614832a36b22,3,

Why is it adding CFID and CFTOKEN to the URL though? I have it turned off in my Application.CFM:

<cfapplication name="yaya" 
    clientmanagement="no" 
    sessionmanagement="no" 
    setclientcookies="no" 
    setdomaincookies="no"
    sessiontimeout="#CreateTimeSpan(0,2,0,0)#" 
    applicationtimeout="#CreateTimeSpan(1,0,0,0)#"
      >
1
regarding the cfid and cftoken, have you tried adding addToken="no" to the cflocation? - luke
Yes I have, but it doesn't seem to matter. But also, jsut outputting the URL to the screen shows the CFID and CFTOKEN in there. - Brian Fleishman
@luke is correct, you have to specify addToken="no" to the cflocation tag in order for it to NOT append that to the URL. If it is still in the URL after doing that then check your database contents getURL.redirectURL for it in there. - Miguel-F
The url you are displaying in your question has a cfid and cftoken. - Dan Bracuk
You should write up your solution so that others can see how this was fixed. - James A Mohler

1 Answers

0
votes

To help others coming here:

cflocation have a parameter addToken which needs to set to no if we do not want to add CFID and CFTOKEN to the generated URL.

Adobe CFML reference: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-j-l/cflocation.html