How to block a domain with .htaccess

Discussion in 'Apache' started by redbayron2006, Dec 24, 2006.

  1. #1
    Dear friends i want to block a specific domain that is targeting mysite (it has a link in it to mysite) as i can get its webmaster to remove it i want this link when its clicked not to appear my site.
    I was informed that i can do that by putting an .htaccess in my httpdocs with the code below:

    order allow,deny
    deny from site.com
    allow from all

    And i do that, but when i go to that site and click the link my site still appears!?!?
    What should i do?
    I tried also to put in its ip but it still dont work anybody knows why?
    Thanks anyway
    :(
     
    redbayron2006, Dec 24, 2006 IP
  2. drig

    drig Peon

    Messages:
    4,188
    Likes Received:
    175
    Best Answers:
    0
    Trophy Points:
    0
  3. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #3
    That sounds good, but as a noob in coding I dont understand anything:eek:
     
    login, Dec 24, 2006 IP
  4. drig

    drig Peon

    Messages:
    4,188
    Likes Received:
    175
    Best Answers:
    0
    Trophy Points:
    0
    #4
    drig, Dec 24, 2006 IP
  5. Mystique

    Mystique Well-Known Member

    Messages:
    2,579
    Likes Received:
    94
    Best Answers:
    2
    Trophy Points:
    195
    #5
    If you are hosted on a linux server add the following link to your .htaccess file:

    
    <Limit GET>
    order allow,deny 
    deny from X.X.X.X
    </limit>
    
    Code (markup):
    That makes the trick ;)

    use www.dnsstuff.com to find the IP from site.com or use cpanel for this.
     
    Mystique, Dec 24, 2006 IP
  6. redbayron2006

    redbayron2006 Active Member

    Messages:
    173
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #6
    Man i dont know what to do.
    Ive put this:

    <Limit GET>
    order allow,deny
    deny from site.com
    </limit>

    after that this:

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?site.com.*$ [NC]
    RewriteRule .* - [F,L]

    before you post this answers -> but nothing happend!!! :( :( :( :(

    I know that because i went to the site.som that i block press my link but my site still appears! Is this a problem in my pc or browser? What do i do wrong i dont know??
    Please helpme a bit cause its vital for me to block this site
     
    redbayron2006, Dec 25, 2006 IP
  7. redbayron2006

    redbayron2006 Active Member

    Messages:
    173
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Should the client that open the page run its machine on Linux in order to work?
    I use windows xp. I dont know what else to think, every page in the internet has the above two examples to block a domain. Which is the diference anyway?
     
    redbayron2006, Dec 25, 2006 IP
  8. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #8
    I also have this problem so its not only you.
     
    login, Dec 25, 2006 IP
  9. drig

    drig Peon

    Messages:
    4,188
    Likes Received:
    175
    Best Answers:
    0
    Trophy Points:
    0
    #9
    RewriteEngine on
    # Options +FollowSymlinks
    RewriteCond %{HTTP_REFERER} badsite\.com [NC]
    RewriteRule .* - [F]
    Code (markup):
    did not work?
     
    drig, Dec 25, 2006 IP
  10. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #10
    The problem might be that he is using both mod_rewrite and <Limit GET> at the same time.

    Try one or another, but not both in the same file
     
    Pat Gael, Dec 25, 2006 IP
  11. Maurice Randall

    Maurice Randall Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    You have to set a variable according to the referrer. You can do it
    like this:

    # start of htaccess code

    SetEnvIfNoCase Http_Referer "site.com" bad_link

    <Limit GET POST>
    Order Allow,Deny
    Allow from all
    Deny from env=bad_link
    </Limit>

    # end of htaccess code

    If you want to add more links to your site that you want to deny, just
    add additional "SetEnvIfNoCase" lines right after or before the existing
    one above, but change the part where it says "site.com". Put the actual
    referring site name there.

    -Maurice
     
    Maurice Randall, Dec 26, 2006 IP
  12. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #12
    Works, thanks a lot

    RewriteEngine on
    # Options +FollowSymlinks
    RewriteCond %{HTTP_REFERER} badsite\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} anotherbadsite\.com
    RewriteRule .* - [F]
     
    login, Dec 30, 2006 IP
  13. Tinkleondabeach

    Tinkleondabeach Well-Known Member

    Messages:
    378
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    Digital Goods:
    2
    #13
    would this be blocking the referrer only? Or the host itself?
     
    Tinkleondabeach, Dec 30, 2006 IP
  14. redbayron2006

    redbayron2006 Active Member

    Messages:
    173
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #14
    This should be blocking refferer only in any page of the domain.
    But ill tell you something weird. I thought it didnt work for anyone, but hear this: it works for anybody else exept me how come? I tell a friend of mine to hit the link from the other domain to mine and it told me that a screen appeared that said forbidden, when i tried it i saw the page just fine!! So i told in two more people to check and it said forbidden! So the problem is in my pc, a cookie or something can anybody imagine?
     
    redbayron2006, Jan 10, 2007 IP
  15. noname

    noname Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    BTW not all browsers send the %{HTTP_REFERER}
    so some of them will escape and reach your site.
     
    noname, Jan 11, 2007 IP
  16. noname

    noname Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #16
    in the mod_rewrite method
     
    noname, Jan 11, 2007 IP