DMIL DMIL - 1 year ago 110
PHP Question

PHP: Changing referer with header()

My CMS links to other sites for convenience and I'd like to hide the referer so that other sites don't see the directory and the query string of my CMS. I now have the CMS linking to a PHP file elswhere on my server which in turn redirects to the link via header() but the referer is still from my CMS, not from the linking PHP. Furthermore...

header("Referer: nowhere");
header("Location: $_REQUEST[urltolinkto]");

... doesn't appear to change anything. No matter what I put as referer, it's always the one from my CMS where the user actually clicked on the link.

Can the referer be changed (to the linking PHP), or do I have to use javascript or meta refresh?

Answer Source

The Referer header is something the browser sends to the Server. You are changing the respose from the server to the browser, so that will not work this way (unlike the Cookie header). As far as I know you have no server-side control of the browser's behavior on sending the Referer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download