December 21 st

18

How to stop spam blogs from hotlinking your images with htaccess

Posted by Andy Bailey
1,329 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% [?]

Category : Blog Tools | Code

Related Posts

  • CommentLuv gets CommentSmothered!
  • An outsourcing experiment..
  • Plugins and tools to help with SEO and affiliate sales
  • CommentLuv, Alexa and AJAX updates
  • Magnetic Sponsoring
  • VWD elottery
  • Oceanside Wealth

  • Comments

    witchypoo (43 comments.) December 21, 2007

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

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

    Andy Bailey December 21, 2007

    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. :-)

    clairec23 (8 comments.) December 22, 2007

    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

    BoVVerred? December 22, 2007

    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!

    Andy Bailey December 22, 2007

    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!

    clairec23 (8 comments.) December 22, 2007

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

    Bobby Revell (34 comments.) December 23, 2007

    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

    Andy Bailey December 24, 2007

    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.

    Bobby Revell (34 comments.) December 24, 2007

    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

    Andy Bailey December 25, 2007

    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?

    Mark @ TheLocoMono (4 comments.) December 29, 2007

    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

    Andy Bailey December 29, 2007

    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

    Mark @ TheLocoMono (4 comments.) December 30, 2007

    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

    Andy Bailey January 2, 2008

    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

    9xmp3 (1 comments.) August 28, 2008

    Leave a comment

    13 online now
    the most online was 176
    elottery Ajax commentluv
    Sponsors
    available ad space available ad space available ad space available ad space available ad space available ad space