Blocking referal urls with .htaccess?

Discussion in 'Apache' started by codyf, Feb 10, 2006.

  1. #1
    Anyone know if there is a way to block referals from other sites.

    Someone signed my site up for one of those adsense click groups where people click eachothers ads and I want to know if I can block everyone coming from that domain.
     
    codyf, Feb 10, 2006 IP
  2. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} (domainyouwanttoblock\.com) [NC,OR]
    RewriteRule .* - [F]
    Code (markup):
    That should do it for ya :)
     
    exam, Feb 10, 2006 IP
  3. codyf

    codyf Guest

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks exam, I'll give it a go.
     
    codyf, Feb 10, 2006 IP
  4. codyf

    codyf Guest

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've tryed this code but all I get is an internal 500 error. I know rewrite is enabled because I use it on other things, any other suggestion?
     
    codyf, Feb 10, 2006 IP
  5. codyf

    codyf Guest

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok, I finally got it working. This is what I used if anyone else has the same problem.

    RewriteCond %{HTTP_REFERER} ^http://www.blockeddomain.com [NC]
    RewriteRule .* - [F,L]
    Code (markup):
    I had to enter the code twice to block the domain with and without the www prefix. So my final code looked like this:

    :D

    Thanks
     
    codyf, Feb 10, 2006 IP