2011-11-23 32 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