.htaccess - how to Protect Php file with the htaccess to protevent external use or a direct use -
if exemple try use php script or external use or direct use want deny him.
 have tried in htaccess : 
rewritecond %{http_referer} !^$ rewritecond %{http_referer} !^http://(www\.)?mydomain.com(/)?.*$ [nc] rewriterule \.(php)$ / [nc,r,l] but doesn't seem working, want allow php script when call in page on server.
 deny/allow way not perfect because it's possible content of php script curl.
you try this:
rewritecond %{remote_addr} !^127\.0\.0\.1$ rewriterule \.(php)$ / [nc,r,l] or without mod_rewrite:
order deny,allow deny allow 127.0.0.1