You're fighting the HTTP specs. In a redirect, the original referrer is preserved as the referrer for subsequent requests.
When the browser requests the redirected-to URL, the browser resends the same referrer details as before in the request header.
edit: fix ambiuguous wording
[edited by: g1smd at 1:48 pm (utc) on Jan 30, 2013]
Okay - the other side then:
Is there a way to forward someone to different page using PHP but something other than a 301 redirect?
I tried almost-instant meta-refreshes but they are blocked by some browsers.
You can proxy the request, but your server has to do twice as much work.
All traffic has to travel into and then out of your server, both for requests and for replies and you also get into all sorts of complexity with X_FORWARDED_FOR headers.
How 'bout the third side: Does it absolutely have to be in the "referer" slot? Or do you simply need to preserve the information in some way? It's obviously trivial to throw a piece into the query string saying "The landing page sent me". And then use that information to do whatever it is you were going to do with the referer.
Also do not forget browsers can (and are) configured to
- not send referrers
- send blank referrers
- always send the top level page as referrer (e.g. this page sends me to www.example.com/yadayada, then my browser fetches that page with a referrer of www.example.com no matter where I can from)
- send some completely bogus information - some even send insults.
Privacy concerns are often at the basis for not sending the referrers you might expect.
yes. (again, long explanation aside) I have to change the multiple referers into one referer before it hits the landing page.
301 forwarding to the landing page with ids or parameters included in the URL is not an option.
You cannot change or even set the referrer: it's the browser that sends it to you. The browser chooses what to send - if anything at all.
You'll have to find another way ...
Maybe it's best to go for the long explanation of why you think you need this so badly.
[sigh] ... here's the dirty laundry facts ...
I generally avoid doing business with family, but my brother has been struggling so I offered to send some traffic his way. He's got 3 kids with a 4th on the way - otherwise I wouldn't be helping.
Now, I know that if he sees the referal names on the traffic I send him from my sources - he'll jump right on them and try to steal those sources. I'm giving him the traffic for cost price. I don't want to end up losing those sources myself.
So - how do I hide the referer so the only thing he sees is my 301ing middle-man domain name? His landing page also needs to see that it is my domain refering it because he has to show an extra snippet to visitors I send him.
One way would be to "proxy" the requests. : you deliver the content of the first html hit yourself (if needed you ask the content from the real server in your scripts). You then can make the change yourself in the content and leave the links like they are so that the second hit and all images etc. come from the real server.
If it were me: Id' go for the proxy: nice and clean and you keep control - esp. with a party you do not trust enough - now you're sure that you keep an amount of control.
Someone has suggested:
I tried it and it seemed to work. It made the referal URl /js/out.php which is what I wanted.