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.

Image Hotlink - Block specific URL

Discussion in 'Apache' started by Big0ne, Dec 18, 2008.

  1. #1
    I would like to block specific url to prevent image hotlinking.

    Does anyone know how to? :)
     
    Big0ne, Dec 18, 2008 IP
  2. SSANZ

    SSANZ Peon

    Messages:
    861
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Got a control panel?
     
    SSANZ, Dec 18, 2008 IP
  3. Big0ne

    Big0ne Well-Known Member

    Messages:
    2,614
    Likes Received:
    81
    Best Answers:
    0
    Trophy Points:
    165
    #3
    Yes I do. What is your suggestion?
     
    Big0ne, Dec 19, 2008 IP
  4. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #4
    You could do it via .htaccess file. Put this rules into your .htaccess file and upload it to your main site html folder (or if you have .htaccess there then just add this lines):

    
    ## SITE REFERRER BANNING
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} badsite1\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} stupidsite2\.net [NC,OR]
    RewriteCond %{HTTP_REFERER} crazysite3\.org [NC]
    RewriteRule \.(jpg)$ - [F]
    
    Code (markup):
    this will block access for those specific sites, 1, 2 and 3 to your .jpg files. If you want to block them from access all other extensions then modify that last line to something like this:
    
    RewriteRule \.(jpg|jpeg|gif|png)$ - [F]
    
    Code (markup):
    that should do the trick. :)
     
    pr0t0n, Dec 19, 2008 IP
    Big0ne likes this.
  5. Big0ne

    Big0ne Well-Known Member

    Messages:
    2,614
    Likes Received:
    81
    Best Answers:
    0
    Trophy Points:
    165
    #5
    Thank you pr0t0n, but somehow I can't get this working.

    After I put this, I was blocking my own site as well.
    I think this is for "allowed" sites not for "blocked" sites.

    Here is my .htaccess

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} verybadsite\.com [NC,OR]
    RewriteRule \.(jpg|jpeg|gif|png)$ - [F]
    Code (markup):
    Please correct me if I am wrong.



    PS: It's working, I think I messed up with notepad++ (invisible breaks).

    Thank you once again pr0t0n, you got greenies! :)
     
    Big0ne, Dec 19, 2008 IP