DotDragnet
May 23, 2012, 09:12:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: follow us on twitter @dotdragnet
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Modrewrite question  (Read 1193 times)
Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2267



ap4a.uk ap4a
View Profile WWW Awards
« on: July 10, 2007, 07:31:37 PM »

One of the rules in my htaccess is set to block connection attempts from anything with an empty useragent string:

Code:
RewriteCond %{HTTP_USER_AGENT} =""
RewriteRule .* - [F,L]

That works quite well and has cut down on a lot of spam and hack attempts on my domain.

However I've now discovered that a legitimate service that I'm subscribed to makes periodic connection attempts via software without a UA string. Not surprisingly they think it best for me to allow their service through, rather than them make an effort to fix the issue with their software. I've already pointed out to them that I'm not the only one that blocks access based on empty UAs, and that there's likely to be other people with a similar issue with their software, but not heard back on that.

On the off-chance they're going to be stubborn and not correct it at their end, is there any way of modifying that modrewrite rule to block empty UAs, except for theirs (based either on their IP or on the file that they're trying to access - preferably IP)?
Logged

JasonD
Global Moderator
Hero Member
*****
Posts: 546



View Profile Awards
« Reply #1 on: July 10, 2007, 09:47:37 PM »

There is no obligation for a UA to identify itself, legitimate or otherwise.

Add a RewriteCond %{REMOTE_ADDR} !="1.2.3.4"
Logged
Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2267



ap4a.uk ap4a
View Profile WWW Awards
« Reply #2 on: July 10, 2007, 09:51:46 PM »

There is no obligation for a UA to identify itself, legitimate or otherwise.

Maybe not everywhere but, when several thousand attempts per month are made to access my comment forms by bots with empty UAs, there is on my site.

Quote
Add a RewriteCond %{REMOTE_ADDR} !="1.2.3.4"

Cheers smile
Logged

Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2267



ap4a.uk ap4a
View Profile WWW Awards
« Reply #3 on: July 10, 2007, 11:03:19 PM »

%{REMOTE_ADDR} !="1.2.3.4"

Couldn't get it to work like that, but it did with this format:

Code:
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
RewriteCond %{HTTP_USER_AGENT} =""
RewriteRule .* - [F,L]

Thanks for pointing me in the right direction though smile
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!