简体   繁体   中英

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:

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. Is there anyway to overcome this with htaccess file?

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 .

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

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.

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