0

I want to know how do I only accept local Ajax call.
I have some pages that I need to use Ajax, however I don't want any external IP to make ajax call in that address, what should I do?
There is some htaccess command or PHP to stop that?

Thanks for help.

Bibhudatta Sahoo
  • 4,808
  • 2
  • 27
  • 51
Thavo
  • 21
  • 4
  • `$_SERVER['HTTP_REFERER']` can work for you – urfusion Jul 07 '17 at 13:21
  • How do I use that on server side? – Thavo Jul 07 '17 at 13:35
  • @Thavo `$_SERVER['HTTP_REFERER']` is a PHP object, so you can _only_ use it on the server side. However, I would recommend actually checking the incoming "origin" header of the ajax call, this would be more accurate. See this answer: https://stackoverflow.com/a/12599921/5947043 – ADyson Jul 07 '17 at 15:17

0 Answers0