If someone for exemple try to use my php script or an external use or also a direct use I want to deny him.
I have tried this in my htaccess :
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com(/)?.*$ [NC]
RewriteRule \.(php)$ / [NC,R,L]
But it doesn't seem to be working, what I want is to allow the php script only when I call it in another page on my server.
The deny/allow way is also not perfect because it's possible to get the content of my php script by CURL
.
You could try something like this:
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteRule \.(php)$ / [NC,R,L]
Or without mod_rewrite:
Order deny,allow
Deny from all
Allow from 127.0.0.1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.