title: PHP - Referer redirect script
body: <p>Often, when searching for answers, I have found that certain websites will allow you to read the information they offer if the referer is, for example, google.com. Yet, if you link directly to the information, it will be unavailable.</p>
  
  <p>What I am looking for is the smallest PHP script that will set a referer of my choice, and a destination, like so:</p>
  
  <pre><code>http://example.com/ref_red.php?referer=http://google.com/&amp;end=http://example.net/
  </code></pre>
  
  <p>Notes:</p>
  
  <ul>
  <li><strong>ref_red.php</strong> is the name of the script on my example.</li>
  <li><strong>referer</strong> and <strong>end</strong> should accept <em>http</em>, <em>https</em>, <em>ftp</em>.</li>
  <li><strong>referer</strong> and <strong>end</strong> can contain an URI of any type, as simple as <a href="http://end.com" rel="noreferrer">http://end.com</a> or as complicated as:
  <code>http://example.com/some/rr/print.pl?document=rr</code>, for example.</li>
  </ul>
  
  <p><strong>NOTE:</strong> As recommended on a reply, I am adding this. The script isn't a full proxy per se. <strong>Only initial HTTP request would be proxied</strong> (not subsequent requests like images,etc) for the <strong>sole purpose</strong> of setting the <strong>referer</strong>.</p>