title: Block direct access to .php files, less the index.php file and ajax.php file
body: <p>been looking for your help, i found a method, but it is not as i wish. if someone can help me.</p>
  <p>What I want is that nobody can enter a direct URL with .php</p>
  <p>example when I enter my domain.com/buy/product.php, I want it to be forbidden,</p>
  <p>I was looking for information here, I found this code that worked for me but in .htaccess</p>
  <pre><code>RewriteEngine On
  
  RewriteCond %{THE_REQUEST} &quot;^.+? [^?]+\.php(?:[?/# ]|$)&quot; [NC]
  RewriteRule !^index\.php$ - [F,L,NC]
  </code></pre>
  <p>it worked fine for me, but the problem that I in a directory /include/ajax.php , I use an ajax. and it gives me error to execute the ajax by browsing.</p>
  <p>Now what I'm thinking how to make it work with that htaccess code that you can enter the index.php and /include/ajax.php, I tried all means but it does not work for me.</p>
  <p>In another case if you know any code to add to my php or how to do for my version which is version 7.3, but without ruining my code.</p>