Looking for a script doing the following: Let's say I have a link on www.container.ext. The link connects to www.link.ext/link.php?ID=123. There is an array in link.php contains a list of URLs that I want the script to redirect to. There should be another array of referrers that I want to spoof the destination site with. When a visitor clicks the link on www.container.ext, s/he will be redirected to www.target.ext with a whatever referrer I want. I don't mind paying for it. Please let me know your price. Budget: $40.
I don't think I need to mention that I need it in PHP, do I? This is *NOT* what I want: <?php header("location: http://www.whatever.ext"); ?> nor meta refresh.
Then theres only a way to read the script from the domain. For example an user comes on your domain. (domain.com) but yuo want the user to see yourdomain.com then you need to readfile/fopen/curl the content of yourdomain.com and display it to the user on domain.com but you will miss alot of images/scripts/stylesheets and other things. It's just best to use header/javascript/meta refresh
It's possible to work around the relative path problems with a single preg_replace call. If you want to spoof referers, your ONLY option is cURL/etc.
I tried this but cURL can only control the server. It has nothing over the client which is the important thing here unfortunatly. Unless there is a way to do this with something like Javascript I dont think its possible.
Try adding ob_start(); before the <?php and ob_end_flush(); before the end of your code e.g. <?php ob_start(); $locationurl = "http://google.com"; header("location: $locationurl"); ob_end_flush(); ?> PHP:
It's impossible to redirect a user to a site and have the referrer spoofed, because the referrer header is sent by the user, not the server that they're being redirected from.
That's the point. It's being sent by the user, so as a user, I should be able to send an incorrect referer.
No errors, and redirect was successful, but correct referers will still show up with and without header("Referer: $referer");
cURL is the only option for spoofing a referer for a page request because the server acts as the visitor and can tell the destination server whatever it wants, if the visitors browser gets ahold of the URL all bets are off. The following will apply a <base> url to the page using the address the page is comming from to force inpage resources to go to the server they're on. For instance if the requested URL is "http://domain.com/folder/page.html" then $url will be "http://domain.com/folder/". $base_url = "<base href='{$url}'>"; $html_returned_from_curl = preg_replace('#(<base[^>]+>|</head>#i', $base_url, $html_returned_from_curl); Code (markup): If the host matches resource requests up to page requests to detect spoofing this will fail however, since the images/css/etc will return the referer as the page you're showing the visitor on your domain.
The header function only works if no output has been displayed in the browser window. Once something is printed to screen it no longer works. To get around that problem, i just use javascript form autosubmit that submits to a page that only contains the header function. But to answer your main question, cURL is the best way for what you wanna do, since you can manually set the referrer.