Posts

Showing posts with the label apache2 blocking

Blocking Bad Bots - .htaccess (Apache2)

Block bad users based on their User-Agent string Sometimes your website can be attacked from different IP addresses and it is impossible to block all such users. If there is fixed user-agent in the request, you can block such access using the following rule: Block multiple bad User-Agents: <VirtualHost  XXX.140.234.34:80 >     ServerName www.example.us     LogLevel debug     ErrorLog /var/log/apache2/example.log     CustomLog /var/log/apache2/example.log combined     AddDefaultCharset utf-8     RewriteEngine On     # Block requests from Amazonbot - this rule sends a 403 Forbidden response ([F]) and stops processing further rewrite rules ([L]).     RewriteCond %{HTTP_USER_AGENT} Bytespider|ClaudeBot [NC]     RewriteRule ^ - [F,L]     RewriteCond %{SERVER_NAME} XXX.140.234.34     RewriteRule /(.*) http://www.example.us/$1 [R=301,L]     LimitRequestBody...