Blocking Specific User Agents

| | Comments (0) | TrackBacks (0)
I came across a situation recently where a site was getting hammered by a couple of different ip addresses. The one thing they had in common was that they were all using the same User Agent, VoilaBot in this case. Instead of blocking each IP using IPTables, the following was added to the .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} VoilaBot
RewriteRule .* - [F,L]
Any client with "Voilabot" in the User Agent now gets a forbidden page.

If you want to ban multiple User Agents, you can do the following:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} UserAgent1 [OR]
RewriteCond %{HTTP_USER_AGENT} UserAgent2
RewriteRule .* - [F,L]

0 TrackBacks

Listed below are links to blogs that reference this entry: Blocking Specific User Agents.

TrackBack URL for this entry: http://www.modrewrite.co.uk/cgi-bin/mt/mt-tb.cgi/2421

Leave a comment

About this Entry

This page contains a single entry by Niall Donegan published on October 11, 2007 12:00 AM.

Canonical Urls With Mod Rewrite was the previous entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01