title: PHP - Detect the incoming url requesting php page from another source/url
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>Many Thanks</p>
  
  <p>In response to the answers below I used the as mentioend and here is what I did:</p>
  
  <pre><code>  $URL_REF = parse_url($_SERVER['HTTP_REFERER']);
    $URL_REF_HOST =   $URL_REF['host'];
  </code></pre>
  
  <p>Thanks @Philip Bevan,@Itai Sagi and @EvilP</p>