How to stop spam blogs from hotlinking your images with htaccess
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….

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% [?]
Tags: code, hotlinking, htaccess, images, protection, tutorial
Print This Post




December 21st, 2007 at 3:13 pm
You’ve always got our backs, Andy. Thanks, and well done.
witchypoo’s last blog post..Working with the police - part three
December 21st, 2007 at 3:30 pm
December 22nd, 2007 at 6:41 am
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
December 22nd, 2007 at 11:16 am
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!
December 22nd, 2007 at 11:38 am
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!
December 22nd, 2007 at 12:51 pm
lol again I say very useful indeed! Nice work Andy
clairec23’s last blog post..Knowledge Ruins My Drink
December 23rd, 2007 at 1:51 am
[...] How to stop spam blogs from hotlinking your images with htaccess - Andy Bailey [...]
December 23rd, 2007 at 9:29 pm
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
December 24th, 2007 at 9:12 am
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.
December 24th, 2007 at 10:27 am
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
December 25th, 2007 at 11:22 pm
I’ve heard a few people say bad things about bluehost, time to jump ship?
December 27th, 2007 at 11:00 pm
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…
December 29th, 2007 at 12:36 am
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
December 29th, 2007 at 11:56 am
thanks for your comments! come back any time
December 30th, 2007 at 11:56 pm
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
January 2nd, 2008 at 7:48 pm
RewriteEngine OnRewriteCond %{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
January 9th, 2008 at 6:29 am
[...] 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. [...]