Block visitor that came from certian domains ??

Discussion in 'Programming' started by A.G, Jul 15, 2007.

  1. #1
    Hello,

    one time I saw code inserted into .htaccess file to block traffic that came from certain domains and redirect it to another page but I lost that code , would you plz put example of the code here ?

    thanks
     
    A.G, Jul 15, 2007 IP
  2. Blue

    Blue Peon

    Messages:
    65
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can do it several ways.

    1) My favorite way for my server is to use mod_security

    Edit your modsec.user.conf and just substitute your data:

    Ban by IP method:
    
    #Google Web Accelator
    SecFilterSelective "REMOTE_ADDR" "^72.14.192.*$" "deny,log,status:412"
    SecFilterSelective "REMOTE_ADDR" "^72.14.194.*$" "deny,log,status:412"
    Code (markup):
    By by domain method:

    SecFilterSelective "HTTP_REFERER" "brandimensions.com" "deny,nolog,status:404"
    Code (markup):
    2) The other way is .htacess.

    This method gives the referrer a 404 page.

    RewriteCond %{HTTP_REFERER} ^http://.*spamdomain1\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*spamdomain2\.biz [NC] 
    rewriterule !(401\.html|403\.html|404\.html|robots\.txt) - [F]
    Code (markup):
    The rewrite rule will allow the spam domain visitors to see your robots.txt/401/403/404 error pages while being served a 404 error.
     
    Blue, Jul 15, 2007 IP