PHP - Detect the incoming url requesting php page from another source/url

前端 未结 2 1410
南方客
南方客 2021-02-13 01:57

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 acce

相关标签:
2条回答
  • 2021-02-13 02:36
    $_SERVER["HTTP_REFERER"]
    

    is what you are looking for.

    0 讨论(0)
  • 2021-02-13 02:41

    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.

    0 讨论(0)
提交回复
热议问题