htaccess rewrite useragent

Written by Peter Davies on .

This is a simple way to redirect any requests to an error page given the user-agent (browser). In this example we had a rogue XML-RPC python application causing havoc on a magento store, so we needed a quick way of reducing the requests and then the subsequent load on the server.

RewriteCond %{HTTP_USER_AGENT} .*python.* [NC]
RewriteRule .* - [R=503]

This then shows up in the "access_log" with a 503 error page: - - [10/Jul/2013:12:46:45 +0100] "POST /api/xmlrpc HTTP/1.1" 503 236 "-" " (by"