views:

231

answers:

4

Hey,

I've setup some redirects on an Apache server. They look at bit like this:

Redirect /Name/register /login.html

My question is this... is there anyway to preserve the HTTP Referrer through this redirect? It would seem that by default, Apache discards the information. I would really like it if after the redirect was complete the referrer was say:

http://the.orginalurl.com/Name/register

Anyone if this is even possible? If not, thoughts on an alternative.

Many thanks, Neil

+2  A: 

Redirect won't preserve the referrer because the browser is sent a 301 and a new address to open. From the manual:

The Redirect directive maps an old URL into a new one by asking the client to refetch the resource at the new location.

mod_rewrite and (I think) Alias can rewrite directly (i.e. without causing a browser redirect) and will preserve the referrer. With mod_rewrite, you can even add the referer as a GET parameter to your request, if you want to.

Pekka
Thanks for the clarification. I had a feeling this was the case, I guess it'll be the mod_rewrite route on this one.
Neil Albrock
+1  A: 

It's a browser issue, not apache. There isn't much you can do about it. This is done to prevent certain security issues and referrer spam.

http://en.wikipedia.org/wiki/HTTP_referrer#Referrer_hiding

The Doctor What
This is not the OP's issue. The issue is that the referer (that is transmitted by the client) gets lost during the redirect.
Pekka
Which is what I said. Or is it that I didn't point out that the `Redirect` directive uses an HTTP redirect? Either way, your answer is better.
The Doctor What
Ahhh I see now. I thought you were not understanding the question, and referring to the fact that some browsers and security suites don't send a referer string at all. My apologies!
Pekka
+1  A: 

You can always store the original referrer in a pipeline variable at the beginning of the request and just pull it from there instead.

kprobst