在IIS中阻止目录访问,但允许通过特定的文件

是否可以通过IIS中的web.config阻止对目录的访问(不包括一小部分IP),但允许每个人通过一个特定的文件。

我问的原因是,我想阻止WordPress的wp-admin目录,但是admin-ajax.php确实需要在外部访问。

谢谢。

为了将来的参考,这是解决scheme:

<location path="wp-admin"> <system.webServer> <security> <ipSecurity allowUnlisted="false"> <clear/> <add ipAddress="ipaddr" allowed="true" /> </ipSecurity> </security> </system.webServer> </location> <location path="wp-admin/admin-ajax.php"> <system.webServer> <security> <ipSecurity allowUnlisted="true"> </ipSecurity> </security> </system.webServer> </location>