我正在尝试以下代码仅匹配如果网址包含某些wordpress页面并且用户代理为空或匹配(curl / perl / php等...)。但是,即使REQUEST_URI不匹配,它也会这样做。陈述的流程是错误的吗?
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^-?$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (havij|libwwwperl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC]
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]
由于
答案 0 :(得分:0)
!
正则表达式前面有%{REQUEST_URI}
。这意味着:
-
您需要删除否定匹配:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^-?$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (havij|libwwwperl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC]
RewriteCond %{REQUEST_URI} ^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]