简体   繁体   English

允许从特定的URL访问并通过admin文件夹上的ip阻止访问

[英]Allow access from specific url and block access by ip on admin folder

I have a php file from the front end that needs to trigger a php file from the admin back-end but it can't do that because i added in .htaccess: 我从前端有一个php文件,该文件需要从管理后端触发一个php文件,但它不能这样做,因为我在.htaccess中添加了:

ErrorDocument 403 "Forbidden
order allow,deny
allow from 182.112.0.1/13
allow from 76.112.0.1/13 ....

And it echo's in the interior of the php file a forbidden error. 并且它在php文件的内部回显了一个禁止的错误。 Is there anyway to overcome this with htaccess file? 反正有使用htaccess文件克服此问题吗?

something like 就像是

ErrorDocument 403 "Forbidden
order allow,deny
allow from 182.112.0.1/13
allow from 76.112.0.1/13 ....
allow from file.php // this doesn't work

You can use mod_setenvif . 您可以使用mod_setenvif

So something like this should work: 所以这样的事情应该工作:

SetEnvIfNoCase Request_URI "file\.php" ALLOWED_PHP

ErrorDocument 403 "Forbidden
order allow,deny
allow from 182.112.0.1/13
allow from 76.112.0.1/13
allow from env=ALLOWED_PHP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM