Redirect images

Discussion in 'Apache' started by MilesB, Aug 10, 2010.

  1. #1
    I have a ton of images being hotlinked from my site. Is it possible to set up a redirect in apache that redirects requests for these images to my main site?
     
    MilesB, Aug 10, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://www\.example\.com/ [NC]
    RewriteRule \.(jpg|gif|png)$ http://www.example.com/this-site-stole-this-image.gif [L]
    
    Code (markup):
    Should get you going.
     
    tolra, Aug 10, 2010 IP
  3. MilesB

    MilesB Well-Known Member

    Messages:
    1,813
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    180
    #3
    So if someone hotlinks the stolen image and embeds on their site it will redirect them to mine?
     
    MilesB, Aug 10, 2010 IP
  4. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #4
    If they hotlink an image on your site then the visitor will see this-site-stole-this-image.gif, you could host that on some free image hosting site if you want to get rid of the bandwidth.
     
    tolra, Aug 10, 2010 IP
  5. detect2173

    detect2173 Peon

    Messages:
    27
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    There is also a function in cPanel (if you are using that) that protects images against hotlinking.
     
    detect2173, Aug 10, 2010 IP