PHP check to make sure request is either xmlhttp from my site or normal request from a certain domain

前端 未结 4 411
心在旅途
心在旅途 2020-12-22 07:13

How would the condition be written to ensure a page is either accessed by xmlhttp request from my site or from an allowed outside domain?



        
4条回答
  •  清歌不尽
    2020-12-22 07:50

    You spelt referrer correctly but unfortunately the person who wrote the HTTP spec couldn't! You need to use HTTP_REFERER.

    You might also want to escape the dot \. so it only matches a dot and not everything.

提交回复
热议问题