块 'kw=' 查询字符串

Block 'kw=' Query String

我的网站不断收到无意义的点击,例如:

此外,如果重要的话,它是一个自托管的 Wordpress 站点。我已尝试对以下内容进行多种排列,但它不起作用:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{QUERY_STRING} kw
    RewriteRule ^(.*)$ - [F,L]
</IfModule>

编辑:我已经在一个单独的目录中测试了上面的代码,它工作正常。下面是我将其缩小到的 Wordpress 块:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{QUERY_STRING} kw
    RewriteRule ^(.*)$ - [F,L]
</IfModule>

# Use PHP5.3 Single php.ini as default
AddHandler application/x-httpd-php54s .php

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress

我能够通过将以下内容添加到 .htaccess

的 WP 块来解决这个问题
# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On

    # These 2 lines block any request coming in with `/?kw=`
    RewriteCond %{THE_REQUEST} \s/+[^?]*\?kw=
    RewriteRule ^ - [F,L]

    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress