views:

850

answers:

2

Are there any HTTP Headers I could use to grab the entire referrer URL using a webserver/server-side scripting? Including query string, et cetera?

+4  A: 

You should be able to grab it from the $_SERVER['HTTP_REFERER'] variable.

Chacha102
I'm aware of this but are there any more http headers, or any other techniques? I believe the referrer can manually modify this http header so I thought there was some other technique that was in use.
meder
The referrer is sent by the Browser I believe. And either way, if someone modifies it, they are going to modify it and you can't really do anything about it. Unperfect world, unfourtunatley.
Chacha102
Chacha is correct, this is what you must deal with.
hobodave
+1  A: 

To add to Chacha's point, I don't know if you want to capture the client side hash part of the referrer URL (sometimes, you do). I.e. if the client came from "http://www.domain.com?x=3#y=5", the $_SERVER['HTTP_REFERER'] will only contain "http://www.domain.com?x=3", and the hash part won't be sent up to the server.

If you want to capture that hash part (officially called the URL fragment), you can only do so if the referring page is your OWN page - i.e. if you can write code on that page. If it is, just send up an AJAX request to your statistics web service that captures referrers, and send the entire URL up (javascript does have access to that part of the URL).

Alex
I'll add that I've done some research, and there are claims that "some browsers" send the hash, but my testing shows that none of the "modern" browsers (that is, IE 6+, Safari 2+, Firefox 2+, Opera 9+, Chrome) send the hash.
eyelidlessness