How to block specific URL requests via htaccess

Discussion in 'Apache' started by wildgras, Jan 3, 2013.

  1. #1
    Hi,

    I have some annoying bandwidth hogger that has compromised a number of computers and sends about 5-10 requests per second to my web server.
    There is one way to identify these requests as they always end with the url /error like in:

    /en/error
    /de/error
    /de/schulung/error

    I have checked online and found various scenarios but I am unable to find a working RewriteCond that would match and send traffic back to caller.
    Can someone help out on this? I need a match to any request where the url ends in /error

    "GET /de/schulung/grundlagen/error HTTP/1.1"

    Thanks a million
     
    wildgras, Jan 3, 2013 IP
  2. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #2
    This will do the trick:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*)error$ - [F,L]
    Code (markup):
    However, it will not deny /de/error/, for example, just anything with error at the end. If you need it with the trailing slash then just add it after error and before the $.
     
    ryan_uk, Jan 3, 2013 IP
  3. wildgras

    wildgras Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the simple reply - this indeed did the trick... was actually simpler than I thought, got lost in all the RegEx stuff of Apache....
     
    wildgras, Jan 3, 2013 IP
  4. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #4
    No problem, mate. I know the feeling... sometimes it seems daunting, especially with RegEx. If you need any further help, don't hesitate to ask.

    Totally emphasise with you about the situation - had similar in the past.
     
    ryan_uk, Jan 3, 2013 IP