Is there a way in which I can detect the URL that is calling in my php page, similar to say a GET or POST but would like to get the URL as I would like to restrict the page accessing it to a certain URL as this file is being called from another server.
Basically: www.MYURL.com calls the php file from say www.PHPURL.com if the URL is NOT www.MYURL.com then bounce them out etc.
Many Thanks
In response to the answers below I used the as mentioend and here is what I did:
$URL_REF = parse_url($_SERVER['HTTP_REFERER']);
$URL_REF_HOST = $URL_REF['host'];
Thanks @Philip Bevan,@Itai Sagi and @EvilP
well, you could use $_SERVER['HTTP_REFERER']
- but it can be cloaked/removed.
EDIT: as someone asked, the HTTP_REFERER is a header which is sent by the client, most browsers default behavior is to send it, but if you'd like, you can disable it or even send a different referer header so people will think you come from some place else.
the bottom line: if it isn't THAT critical for you, you can use it, but don't EVER, EVER give people extra privileges based on their referer alone.
$_SERVER["HTTP_REFERER"]
is what you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With