1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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