How to stop spam blogs from hotlinking your images with htaccess

Tags:
1,226 views

It’s a pain in the arse when someone copies your content, especially when they hotlink your images so your bandwidth gets used instead of their own so here’s a neat way of adding to your .htaccess file so you prevent particular blog networks from displaying images from your hosting by hotlinking them.
Use this code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
RewriteRule .*\.(jpe?g|jpg|gif|bmp|png)$ http://www.commentluv.com/images/antihotlink.jpg [L]
</IfModule>

Just open up your .htaccess file (found in the root of your web space) and add the above lines. That should prevent blogs from myspace,blogspot and livejournal from hotlinking your images. You can add the url of a blog you know is hotlinking your images by following the format of the other RewriteCond statements.

Change the image url for the RewriteRule to one you have hosted somewhere (not on the same hosting because that will get redirected in a loop every time it is linked to).

It works pretty well, look at this screen shot of a self confessed content copier….
Content Thief owned

There a couple of my posts on that blog and they are littered with images telling the (probably non existent) readers to come and read the article here instead. Another reason to always have an image in my articles!

It’s a shame there isn’t a way to do that with content though! If you are having trouble with spam blogs scraping your content and images, you can read a fantastic article here on what to do when someone steals your content by Lorelle who has a treasure trove of Wordpress and blogging information. Well worth a look!

Popularity: 6% [?]

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: , , , , ,

Print This Post Print This Post

Related Posts

  • An outsourcing experiment..
  • CommentLuv gets CommentSmothered!
  • Plugins and tools to help with SEO and affiliate sales
  • CommentLuv, Alexa and AJAX updates
  • easy ecommerce, AJAX and professional designs
  • Coming soon to a weekend near you…
  • Go with the flow joe! New CommentLuv version started
  • 17 Responses to “How to stop spam blogs from hotlinking your images with htaccess”

    1. 1
      witchypoo (35 comments.) Says:
      MyAvatars 0.2

      You’ve always got our backs, Andy. Thanks, and well done.

      witchypoo’s last blog post..Working with the police - part three

    2. 2
      Andy Bailey Says:
      MyAvatars 0.2
      ur welcome! I know this is a bane of many a bloggers life. Nice to know you can advertise your blog on their copied posts at least. :-)
    3. 3
      clairec23 (8 comments.) Says:
      MyAvatars 0.2

      Thanks for that, very useful indeed! I love how it looks on the thief’s blog ;)
      clairec23’s last blog post..Knowledge Ruins My Drink

    4. 4
      BoVVerred? Says:
      MyAvatars 0.2

      Hey Andy Bailey - its good to know that you wasted all your time trying to advertise on my website - I am really am THAT bothered about having your post on my site that I deleted it. Clearly you have too much time on your hands! Have a nice Christmas y’all!

    5. 5
      Andy Bailey Says:
      MyAvatars 0.2
      claire: as you can see from the comment below yours, it works well enough to put the thief into bovvered mode :-) lol
      Ray St Clair: it took as much time as it took you to comment (and less time than it took for you to copy and paste my entire article and change all the links to your own) but thanks for the concern!
    6. 6
      clairec23 (8 comments.) Says:
      MyAvatars 0.2

      lol again I say very useful indeed! Nice work Andy ;)
      clairec23’s last blog post..Knowledge Ruins My Drink

    7. 7
      13 Great Articles - December 23, 2007 | My lucky number 13 Says:
      MyAvatars 0.2

      [...] How to stop spam blogs from hotlinking your images with htaccess - Andy Bailey [...]

    8. 8
      Bobby Revell (33 comments.) Says:
      MyAvatars 0.2

      Nice post Andy! I have had a load of bandwidth issues with my host, so I must preserve every bit I can. I had a tag cloud in my side bar which I had to remove as it was sucking me dry (that sounds quite disturbing…hahaha)

      Blue host told me to go through all of my mysql errors and individually tweak each individual query…hahahahahahaha!!! What? Are they insane? When they are advertising that you can have unlimited domains on one account..they failed to mention running just one domain may be too much for their servers to handle.

      I think I’m going to go with a dedicated server sometime soon:)

      Bobby Revell’s last blog post..Merry Christmas To My Blogging Buddies

    9. 9
      Andy Bailey Says:
      MyAvatars 0.2
      bobby: I’d love to have a dedicated server! I’m doing ok with heartinternet reseller package at the moment, over 30 domains all working fine with their own hosting for 2 years now.

      I think I will look into a dedicated server for next year though, I’m worried about ease of use though as I’ve never configured one before.

    10. 10
      Bobby Revell (33 comments.) Says:
      MyAvatars 0.2

      I am really frustrated with my blue host account…most people who have accounts with them are not having the same problems I am. I cannot figure out what the problem is. I want to start my new site but with only one site causing bandwidth issues, two sites would clog it up. I have been on the phone with my host no less than 20 times this month. I use the wp-cache plug in but that doesn’t seem to help. I don’t know how to correct mysql queries and having my host telling me to adjust them by myself has me irritated.

      On most hosts I’ve seen, you can import any word press blog as long as it’s 2 MB or smaller. Mine is 4 MB. If I change hosts…and it only allows a 2 MB import…how do I import one much larger? I read some tutorials but they are complicated…requiring vast knowledge of both php and mysql. Blue host told me I may need to spend several hundred dollars an hire a database engineer!!!!!!

      Bobby Revell’s last blog post..Merry Christmas To My Blogging Buddies

    11. 11
      Andy Bailey Says:
      MyAvatars 0.2
      OMG! I’ve been really lucky with my hosting, it’s rarely had a problem and tech support is quick and helpful.
      I’ve heard a few people say bad things about bluehost, time to jump ship?
    12. 12
      bloggingzoom.com Says:
      MyAvatars 0.2

      How to stop spam blogs from hotlinking your images with htaccess > FiddyP…

      how to stop blogger and other type blogs from hotlinking your images by editing your htaccess file to point to a different image instead.

      It works! see the comment from the content thief below the post.

      Implement it on your site today with some simp…

    13. 13
      Mark @ TheLocoMono (4 comments.) Says:
      MyAvatars 0.2

      Amazing article, Andy. You can bet your FiddyP I am going to add this to my file tonight. One question, does this also affect other sites beside the ones you have listed?

      I use HostICan. I had thought about BlueHost but decided against it due to the popularity of it. HostICan has done well by me. I don’t know about importing or anything but it is worth checking out.

      Keep up the terrific work, Andy. I am rooting for you.

      Mark @ TheLocoMono’s last blog post..Testing New Plugins

    14. 14
      Andy Bailey Says:
      MyAvatars 0.2
      this one prevents hotlinking from blogspot, livejournal and myspace pages. you can add others by following the same format.

      thanks for your comments! come back any time

    15. 15
      Mark @ TheLocoMono (4 comments.) Says:
      MyAvatars 0.2

      Is there a “universal” way to prevent all websites from hotlinking to my images? It seems like it would be a chore to add each time I discover a website hotlinking to my images and adding site by site to the list.

      Mark @ TheLocoMono’s last blog post..K.I.S.S. $1000 per Month

    16. 16
      Andy Bailey Says:
      MyAvatars 0.2
      Mark: yes mate, just use this code
      RewriteEngine On
      RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
      RewriteCond %{HTTP_REFERER} !^$
      RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

      where mysite is the name of your site

    17. 17
      Wordpress Plugin to help comment interaction. | IM Blogging | Quality Ebooks - you deserve to have it all! Says:
      MyAvatars 0.2

      [...] This blog, FiddyP, also has some very interesting Blogging Tools entries, and may be worth your time checking them out. For example, I like the spot on How to Prevent Hotlinking images with Htaccess: Here. [...]

    Leave a Reply

    Blog Comment Policy
    I encourage comments on this blog and really appreciate people taking the time to add to the discussion. I use dofollow and CommentLuv so there is more incentive to leave relevant comments. However, comments that are made for the sole purpose of getting a link back to your site or using key words or phrases as your name will have the url and last blog post removed. Anonymous comments are welcome but only if they contribute to the discussion. You are fine to disagree with my post, but being rude to me or other people that comment will see your comment removed and your IP banned.