IMPORTANT : as noted by @cryptic and @Bartdude The following solution is tempting but won't work. Why this won't work is explained below.
--- Original solution ---
Add Referer
header also
header("Referer: http://www.the_referer_page");
The Referer
is sent by the browser to the server. Because you are redirecting to another site you have to manually send the header to the other site as there is no browser involved.
--- Original solution end ---
Why the above solution wont work
The HTTP referer
is sent by the browser to the server. When the 301 Moved Permanently
header is sent to the browser the server is telling the browser that this page is moved and load the page from the new location. It is then the browser's decision to request or don't request the page from the new location and what all the headers to be sent to the new server. Actually sending a HTTP referer
header to the browser is really meaningless.
Sorry for the wrong solution provided. Hope this avoids someones temptation to use the Referer
header as it tempted me.