A Cool Redirect for Scraped Image Content: Stop Hotlinking

by on February 9, 2012

in consumer

Consumer Bits on Brusimm 200w logo, [Consumer News, advice and reviews]As a website owner and one who has chosen to play in the hobby of blogging, one ever so slowly gets introduced to the many intricacies of this realm of fun.

From the supposed semantics of SEO to get better search engine results, to the relationships that come and go online, it’s a fascinating realm. One of those realms of this business includes when other unscrupulous websites start scraping your content or imagery from your site.

The scraping of content can feel like a violation to a degree. It’s maddening to see your work replicated somewhere else, being monetized by those other sites. Then there’s the situation when other websites link out to your imagery, and use your images in their content. If you have limited bandwidth, this can be an interesting aggravation.

Grr. I can’t decide if it’s an honest mistake or intentional evil deeds. So I tempered my defensive action. That action is a way to redirect third party burrowing links so that

A: Stop the bandwidth leakage

B: Show an image of your choosing on their website.

(Me, I installed this feature as a matter of principal.)

I’d recommend checking out my source link below for this info for a wee bit more info. I’ve already applied this and other tools to my site that are a bit entertaining but I’d love it if you confirmed my work. I’d rather you be safer than sorry! They explain what each line does. I’ve employed these lines of regular expressions and after a few tests, seem to work. Onward….

You will be editing your ‘.htaccess’ file, SO BACK THINGS UP BEFORE you start editing. Then, somewhere in your .htaccess file, add the following:

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yoursite.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds.feedburner.com/yoursitefeed [NC]
RewriteCond %{HTTP_REFERER} !google. [NC]
RewriteCond %{HTTP_REFERER} !search?q=cache [NC]
RewriteCond %{HTTP_REFERER} !bing. [NC]
RewriteCond %{HTTP_REFERER} !msn. [NC]
RewriteCond %{HTTP_REFERER} !yahoo. [NC]
#RewriteRule \.(gif|jpg)$ [F]
RewriteRule \.(gif|jpg)$ yourchoiceofanewimage.jpg [R,L]

That last line could possibly be a moot point, depending what you put there. You’re blocking access from another site to an image on your site, in the hopes to eliminate the bandwidth usage. I am lucky enough to have a different website and I’ve planted a wonderful image on my other site for these hotlinking websites to now show. It’s nothing evil. It’s just a note to come by here to see how to block hotlinking.

If you don’t have another website, maybe a photo hosting site and an image placed there? Or just a teeny tiny image on your site.

To be honest, I’m not sure what happens if you don’t have that last line. But regardless, there’s a pretty cool trick. I’ve been changing the picture everyday cause I’m bored. Sooner or later I’ll tire of that and leave it alone.

In the meantime, PLEASE, go check my source or do a Google search for blocking image hotlinking. I am using this but suggest you play it safe for your own site.

If anything, open up that FTP client, save your htaccess file off-site. Edit the online version, and see what happens. If something goes horribly awry, FTP the original back in place. Always have a backup!

[source: The Web Squeeze: Stop Image Hotlinking]

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: