Block Traffic from Certain Sites

Discussion in 'Site & Server Administration' started by A.G, Jun 8, 2009.

  1. #1
    Hello,

    I have serious problem , some Chinese forums hotlinking images from my site and I even delete those images they keep sending me huge amount of http requests to my hosting server and eating up to 800mb of memory and it goes sometime to 1GB cause server crash:(

    am tired I have tried to block incoming referrer traffic from those sites using htaccess but it didn't work , I still see their http request on my server logs and memory keep goes high and I get crash every hour

    please tell me how can I block these http request from these domains , what is the right htaccess code , I use DirectAdmin panel by the way

    here example of Chinese forums that send this http requests
    http://75.125.41.20/viewthread.php
    d.mimii.info

    thanks
     
    A.G, Jun 8, 2009 IP
  2. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #2
    Have you tried manually creating/editing the .htaccess file?

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
    Code (markup):
    This checks to see if the request in coming from yoursite.com, and if so, allows the images to be displayed. If it does not, then the browser recieves a 403 Forbidden Error.
     
    RHS-Chris, Jun 8, 2009 IP
  3. A.G

    A.G Well-Known Member

    Messages:
    2,510
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    150
    #3
    thank you but I want to allow sites to hotlink images except the Chinese forums not allowed to hot link
     
    A.G, Jun 8, 2009 IP
  4. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #4
    Try this then:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?domain1\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?domain2\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?domain3\.com/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
    Code (markup):
    Just replace domain(1-3) with the domain names that you do not wish to allow hotlinking. You can add more if you want, just make sure the second last line has the only [NC].
     
    RHS-Chris, Jun 8, 2009 IP