htaccess - 重写规则[f,l]不起作用?

时间:2016-05-06 17:54:04

标签: apache .htaccess mod-rewrite

我试图保护我的网站不受间谍活动的影响。我查了一下日志,发现了很多东西:

38.87.46.132 - - [06/May/2016:19:34:40 +0200] "GET /?option=com_k2&view=itemlist&task=user&id=465707 HTTP/1.0" 200 11955 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0"
155.94.179.172 - - [06/May/2016:19:34:24 +0200] "GET /component/user/?task=register HTTP/1.0" 404 9092 "http://www.example.com/index.php?option=com_user&view=register" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0"
155.94.179.172 - - [06/May/2016:19:34:22 +0200] "GET /index.php/component/user/?task=register HTTP/1.0" 301 670 "http://www.example.com/index.php?option=com_user&view=register" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0"
38.87.46.132 - - [06/May/2016:19:34:40 +0200] "GET /?option=com_k2&view=itemlist&task=user&id=465707 HTTP/1.0" 200 11955 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0"

我已经为htaccess添加了一些内容:

<IfModule mod_rewrite.c>
RewriteRule ^component/k2/itemlist/user/\d* - [F,L]
RewriteRule ^option=com_k2/\ - [F,L]
</IfModule>

但仍无效,网站加载速度越来越慢......

1 个答案:

答案 0 :(得分:0)

这是我的htaac​​cess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^component/k2/itemlist/user/\d* - [F,L]
RewriteRule ^component/k2/itemlist/\d* - [F,L]
RewriteRule ^component/user/\d* - [F,L]
RewriteRule ^component/k2/\d* - [F,L]

RewriteCond %{QUERY_STRING} option=com_ [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{QUERY_STRING} index.php?option=com [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{QUERY_STRING} action=register [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{QUERY_STRING} index.php?action=register [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{QUERY_STRING} compontent [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{QUERY_STRING} index.php/compontent [NC]
RewriteRule ^(.*)$ - [F,L]


</IfModule>

但是仍然有一些网址被阻止,我打开服务器,5分钟后因为大量的请求而下降..