本文介绍了块'kw ='查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在胡说八道,例如:
I keep getting nonsense hits to my site like:
- myurl.com/?kw=防病毒*保护
- myurl.com/?kw=a+赌场
- myurl.com/?kw=.confused.com
- myurl.com/?kw=任何废话
此外,如果有关系,它是一个自托管的Wordpress网站.我已尝试对以下内容进行许多排列,但无法正常工作:
Also, if it matters, it is a self-hosted Wordpress site. I've tried many permutations to the following, but it isn't working:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} kw
RewriteRule ^(.*)$ - [F,L]
</IfModule>
我已经在单独的目录中测试了上面的代码,并且工作正常.以下是我已将其缩小到的Wordpress块:
I've tested the above code in a separate directory, and it works fine. Below is the Wordpress chunk I've narrowed it down to:
<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块中来解决此问题
I was able to fix this by adding the following to the WP chunk of the .htaccess
# 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
这篇关于块'kw ='查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!