Stripping a query string on blank referrers - Posted (1912 Views)
Senior Member
bobby131313
Posts: 1163
1163
This is kind of an odd situation that I'm having a little trouble with. I've got most of it licked but have one little step I can't get.
I have a site that I need to load different links based on the referrer. I've got that part down. I use a query string to load a different navigation menu to stay consistent through the session based on the initial external referrer.
This query string is &al=no. My problem is when someone bookmarks a page with this query string included. I need the query string to be stripped when the page loads from the bookmark. If I can figure out how to strip it when the referrer is blank I'd be in business.....
if (Request.ServerVariables("HTTP_REFERER") = "") then
I'm lost after that. Can this be done? Can someone help?
Thanks in advance.<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Advanced Member
Etymon
Posts: 2396
2396
Take a look at admin_config_badwords.asp and find these lines:

Code:
if (Instr(txtReplace, "  ") > 0 ) then
Err_Msg = Err_Msg & "<li>Two or more consecutive spaces are not allowed in the Replacement word.</li>"
end if

Based off of that code, imagine that txtReplace was your link to search for unwanted characters and image that the area between the quotes is what you want to strip out which seems to be this: &al=no ... change the code between the if and end if area to do what you want which seems to be to strip out the &al=no part. But you need to change your terminology concerning the word strip. Exchange the word strip for the word replace, and you will be in a better frame of mind to understand the answer I am offering.
It seems that what you want to do is replace &al=no with nothing which would look something like replace(WhatEverYourLinkVariableIsGoesHere,"&al=no","")

Based off of the above, try something like this:

Code:
if (Instr(WhatEverYourLinkVariableIsGoesHere, "&al=no") > 0 ) then
WhatEverYourLinkVariableIsGoesHere = replace(WhatEverYourLinkVariableIsGoesHere,"&al=no","")
end if



<
Posted
Advanced Member
Carefree
Posts: 4224
4224
Something like this will eliminate the query string from the address.
Code:
if (Request.ServerVariables("HTTP_REFERER") = "") then
Destination=((Request.ServerVariables("HTTP_HOST"))+(Request.ServerVariables("URL")))
else
Destination=(your routine to use referrer)
end if
Response.Redirect Destination
<
Posted
Forum Admin
HuwR
Posts: 20611
20611
you are away that many so called internet security suites (notably norton) mask the httpreferer string in the browser so for a lot of people your code won't work anyway<
Posted
Advanced Member
Carefree
Posts: 4224
4224
The only thing that should result would be that those people who mask the referer value will all lose their query string values and go to the default URL.<
Posted
Forum Admin
HuwR
Posts: 20611
20611
yes, well unfortunately that is actually quite a lot of people. that is why we had to rewrite quite a lot of the forum code which relates to registrations and logins.
It is not the people who mask it, they are generally blissfully unaware that there is anything wrong.<
Posted
Senior Member
bobby131313
Posts: 1163
1163
Thanks everyone for your help.
I've got it working pretty well using blank referrers to deal with the bookmarks. As Huwr said it's not perfect, however for my situation, it's close enough.

I did some testing and it seems that the newer versions (tested Norton 360) of NIS have stopped stripping the referrers, it's just the older ones.
Thanks again!<
 
You Must enter a message