I use following rule to block requests based on some User Agents using modRewrite
RewriteCond %{HTTP_USER_AGENT} ^.*(SCspider|PetalBot|ZyBorg).*$ [NC]
RewriteRule ^.*$ - [F,L]
OR
RewriteCond %{HTTP_USER_AGENT} ^.*(SCspider|PetalBot|ZyBorg).*$ [NC]
RewriteRule .* - [F,L]
But I need to know if there is any better way (quick & fast) and less resource consumption to block/drop the requests
appreciate for any help
With your shown samples try following. Following should be faster than your tried one.
RewriteCond %{HTTP_USER_AGENT} (?:SCspider|PetalBot|ZyBorg) [NC]
RewriteRule ^ - [F,L]
Suggested improvements:
.*
in condition part since anything that contains these strings should be blocked, you could change it to \b(?:SCspider|PetalBot|ZyBorg)\b
to avoid partial matches too(just in case)..*
we could simply use ^
to avoid matching everything, since we are anyway doing that match in Condition part.