Change the reffer information before requesting a page.

Hi everyone!

Ok, here's my problem...

I am trying out a new forum system, but the site protects against session hijacking by using a URL like this:

http://www.vbmysql.com/fudtest/index.php/f/2/?SQ=1069280974

the ?SQ=1069280974 section is the root of my problem. I use Google adsense with my site, and it has the following piece of code for inlining a context-sensitive ad:

<script TYPE="text/javascript"><!--
google_ad_client = "pub-2660766695269970";
google_alternate_ad_url = "http://www.vbmysql.com/includes/amazon.html";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_color_border = "2184BD";
google_color_bg = "FFFFFF";
google_color_link = "666666";
google_color_url = "000000";
google_color_text = "000000";
//--></SCRIPT>
<script TYPE="text/javascript"
  SRC="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</SCRIPT>

So here's the thing, I am fairly certain that Google must be using the referrer information to do a database lookup and send the best ads for the page requested, well the ?SQ portion of the URL is of course going to drive Google batty. My Apache logs show that google is indeed spidering with the ?SQ portion in place, and things just do not work out well.

What I am wondering is this: Can I have Javascript strip the ?SQ=98672387 portion of the referrer information, THEN call for the  show_ads script and finally put the ?SQ=something portion back so that the forum software does not false alarm a session hijack?

If this is possible great! Please be aware that my Javascript experience is minimal and I will need working code to award points.

Thanks!
LVL 17
SqueebeeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WitchazelCommented:
WitchazelCommented:
i think what you are asking cant be done,   you can easily break the url to pieces, but you cannot change the url in the browser address box (would be nice, i might even try frames if you could hehe)
devicCommented:
<script>
if(top.location.href.indexOf("?")!=-1){top.location.href=top.location.href.split("?")[0]}
</script>
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

devicCommented:
better to change your forum :) but if you put code above in first line, then will be redirect quickly.

so like this:
===============================================================
<script>
if(top.location.href.indexOf("?")!=-1){top.location.href=top.location.href.split("?")[0]}
</script>
<html>
<head>
SqueebeeAuthor Commented:
I will check that out, but does the contents of the location bar determine what the referrer information will be?

Can we influence the external .js file?
devicCommented:
>>>I will check that out, but does the contents of the location bar determine what the referrer information will be?
no it lost referrer. To test it, you can always i in adress bar write javascript:alert(document.referrer) and press enter

i just saw, that if i replace location, i see google ads.

>>>Can we influence the external .js file?
every script can be placed in the external .js file.

<script src=myscript.js></script>
======myscript.js=========
if(top.location.href.indexOf("?")!=-1){top.location.href=top.location.href.split("?")[0]}
SqueebeeAuthor Commented:
I was referring to influencing the .js file at

<script TYPE="text/javascript"
  SRC="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</SCRIPT>

I have implemented your suggestion and it looks like it may be working, I will just have to give it some time and watch the logs to make sure the googlebots are seeing things right.
SqueebeeAuthor Commented:
Ok, your suggestion is good, but doubles all my traffic and does not seem to be working too well to boot.

Here's a question, the following if from google's javascript at the link above:

if (window.google_page_url == null) {
  google_page_url = document.referrer;
  if (window.top.location == document.location) {
    google_page_url = document.location;
  }
}

This seems to be what determines the url that gets passed to google for searching. Now I cannot understand Javascript too well but is there something we can do before passing it to google to fool it into thinking there is no query string? Would this just involve relocating your code snippet further down?
devicCommented:
google_page_url=document.referrer.split("?")[0]

:)

place it in head, before include of google:


==========================
<script>
google_page_url=document.referrer.split("?")[0];
</script>
<script TYPE="text/javascript"
 SRC="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SqueebeeAuthor Commented:
It world, but Google says it is not allowed, how ironic.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.