[英]How to block certain HTTP request with mod_rewrite?
The created RewriteCond regex dont catch the log excerpt, although its tested. 创建的RewriteCond正则表达式不会捕获日志摘录,尽管经过测试。 Hence the request doesnt get blocked as expected.
因此请求不会按预期被阻止。
I would like to block requests to the below URL 我想阻止对以下网址的请求
The RewriteCond statements regex was tested against the log excerpt with regex101.com, but doesnt seem to catch the excerpt when applied on the server. RewriteCond语句正则表达式使用regex101.com对日志摘录进行了测试,但在应用于服务器时似乎没有捕获摘录。
First I tried the whole Request URL, but even (the much shorter) RewriteCond below, dont catched the Request. 首先我尝试了整个请求URL,但是下面甚至(更短的)RewriteCond也没有抓住请求。 I also tried
我也试过了
Request that should be blocked: 应该被阻止的请求:
www.foobar.com/?eID=FOO&type=bar&search%5Bthis%5D%5Bthat%5D%5Btest%5D%5Blatitude%5D=11.1111111111111
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(\/)[?](eID=FOO)$ [NC]
RewriteRule ^.*$ - [F,L]
</IfModule>
RewriteCond %{REQUEST_URI} ^(\/\?)(eID=FOO)$ [NC]
I expected the request to be blocked. 我希望阻止请求。 But none of the above works.
但以上都没有。
Any help is greatly appreciated. 任何帮助是极大的赞赏。 Thanks.
谢谢。
Best regards, 最好的祝福,
Marc 渣
Insted of REQUEST_URI try the below mention QUERY_STRING and make sure that rewrite_module is Loaded or Enabled REQUEST_URI的insted尝试下面提到QUERY_STRING并确保rewrite_module已加载或已启用
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*(eID=FOO).* [NC]
RewriteRule ^(.*)$ - [F,L]
</IfModule>
LoadModule rewrite_module /opt/jboss/httpd/lib/httpd/modules/mod_rewrite.so LoadModule rewrite_module /opt/jboss/httpd/lib/httpd/modules/mod_rewrite.so
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.