Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图拒绝访问某个 uri,即/admin/并尝试过这个 .htaccess 文件:
/admin/
SetEnvIf Request_URI !^/admin/ not_admin_uri Order deny,allow Deny from all allow from 356.244.33. allow from env=not_admin_uri
这适用于示例 IP 范围,但不适用于“not_admin_uri”部分。
这里出了什么问题?
也许尝试使用重写规则。如果不是来自您的 IP,则阻止访问。
RewriteEngine On RewriteCond %{REMOTE_ADDR} !^123\.123\.123\. RewriteRule ^admin/? - [F,L]
要否定匹配,您不能将!其放入SetEnvIf指令中。您需要像这样使用负前瞻:
!
SetEnvIf
SetEnvIf Request_URI ^/(?!admin/) not_admin_uri