2011-11-23 64 views
2

我有一个是越来越受到用户打到这个URL /index.php?s=阻断与.htaccess文件错误请求

我试图阻止以下字符串的所有请求的变化打一个网站,应该摆脱所有的垃圾邮件制造者php?s =

我似乎遇到的问题是?和=在htaccess文件是受保护的字符,我只是无法得到正确的语法。如何在以下情况下使用php?s =

我已经试过

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_URI} ^.(*php?s=).* [NC] 
RewriteRule ^(.*)$ - [F,L] 
</IfModule> 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_URI} ^.*php?s=$1&%{QUERY_STRING}.* [NC] 
RewriteRule ^(.*)$ - [F,L] 
</IfModule> 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{THE_REQUEST} ^.*(php?s=$1&%{QUERY_STRING}).* [NC] 
RewriteRule ^(.*)$ - [F,L] 
</IfModule> 

但没有任何工作。请帮助!

回答

1

尝试

#all .php requests with s= in querystring 
RewriteCond %{REQUEST_URI} ^.+\.php$ [NC] 
RewriteCond %{QUERY_STRING} ^s=.*$ [NC] 
RewriteRule . - [F,L] 

如果你想防止s=任何查询字符串位置替换上面

#block s= in any location 
RewriteCond %{QUERY_STRING} ^(.*&)?s=.*$ [NC] 
+0

谢谢小号!这很好。垃圾邮件发送者被阻止! – Jake