Forum Moderators: phranque

Message Too Old, No Replies

htaccess HTTP USER AGENT restrict

htaccess browser user agent restrict flood

         

Seregwethrin

11:59 am on Jun 21, 2007 (gmt 0)

10+ Year Member



Hello;

I want to protect my web site with htacces. I want to allow only internet explorer, firefox, opera because of bot attacks.

RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR] 
RewriteCond %{HTTP_USER_AGENT} ExtractorPro
RewriteRule ^.*$ X.html [L]

For example this code makes EmailWolf and ExtractorPro agents send to x.html, but other user agent open default url. But i want to restrict other agents, with else or not equal syntax.

How can i do this?

jdMorgan

5:06 am on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This answers your specific question, but I don't recommend it:

# Rewrite requests from all user-agents except modern Internet Explorer, Firefox, Opera
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/4\.[0-9]+\ \(compatible;\ MSIE\ [0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/5\.0 \(([^;]+;\ )*[^;]+\)\ Gecko/2[0-9]{3}\ Firefox/[0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Opera/[0-9.]+
RewriteRule .* X.html [L]

Alternate end rule to return 403-Forbidden response:

RewriteRule .* - [F]

Jim

Seregwethrin

8:42 am on Jun 23, 2007 (gmt 0)

10+ Year Member



Thank you jdMorgan.