Stripping a query string on blank referrers

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/67755?pagenum=1
05 November 2025, 10:42

Topic


bobby131313
Stripping a query string on blank referrers
03 October 2008, 20:40


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.<

 

Replies ...


Etymon
04 October 2008, 01:13


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



<
Carefree
04 October 2008, 02:19


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
<
HuwR
04 October 2008, 03:40


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<
Carefree
04 October 2008, 04:28


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.<
HuwR
04 October 2008, 11:16


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.<
bobby131313
21 October 2008, 13:44


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!<
© 2000-2021 Snitz™ Communications