How to deny hotlinking from 1 site

Discussion in 'Apache' started by jredrum, Sep 30, 2008.

  1. #1
    I have an image hosting site, that I want to block and/or replace the image that shows up on the site when hotlinking. How would I go about doing this using .htaccess?
     
    jredrum, Sep 30, 2008 IP
  2. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #2
    kailash, Oct 5, 2008 IP
    chandan123 likes this.
  3. chandan123

    chandan123 Prominent Member

    Messages:
    11,586
    Likes Received:
    578
    Best Answers:
    0
    Trophy Points:
    360
    #3
    Kailash thanks +rep ;)
    but we can use via cpanel also right ?
     
    chandan123, Oct 5, 2008 IP
  4. jredrum

    jredrum Peon

    Messages:
    168
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you for that, but I'm trying to just deny 1 particular site while allowing anyone else to use it. Is there a way to do that?
     
    jredrum, Oct 6, 2008 IP
  5. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #5
    Not sure if it is possible. But instead of this you can block that site IP address in your htaccess file.

    deny from Site_IP_Address
    Code (markup):
    Kailash
     
    kailash, Oct 6, 2008 IP
  6. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #6
    Yes, cPanel has this feature added. So we do not need to write code in htaccess for cPanel server. I am not sure if other hosting control panels provide hotlinking feature so we can block it using htaccess.

    Kailash
     
    kailash, Oct 6, 2008 IP
  7. dpsubi1

    dpsubi1 Notable Member

    Messages:
    9,318
    Likes Received:
    420
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Yes it is possible. Some image hosting sites will block all their images from adult sites or forums. But, am not so sure how they do it.
     
    dpsubi1, Oct 6, 2008 IP
  8. seismic2

    seismic2 Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Lets say that the site you want to block your images from is example.com

    Here's the code :
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} ^http://(www\.)?example/.com/.*$ [NC]
    RewriteRule \.(gif|jpg|bmp|png)$ - [F]
    Code (markup):
     
    seismic2, Oct 11, 2008 IP