Answer the question
In order to leave comments, you need to log in
How to allow access to php in ajax?
Moderators, correct me please
Hello again! I am interested in such a question, I can’t solve it.
There is such a site structure (this is an example, do not describe relatives)
/public_html
- php
-- reg.php
-- .htaccess
- index.php
- .htaccess
http://site.name/php/reg.php
so that it is not available to him, like, say, a 404 error, and if I write in ajax
Then I need it to allow him access, how to do this? What code should be written in php folder in . htaccess url: "/php/reg.php"
Answer the question
In order to leave comments, you need to log in
There is no reliable way to determine that the request was made through Ajax, does not exist. You can use several different methods of verification, but such a system is easy to "bypass".
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{
header("HTTP/1.0 404 Not Found");
exit();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question