Search
Close this search box.

Stop Image Hotlinking

In a fair world people would create their own unique content or give credit to authors where it’s due.

Very Fluffy Bunny
credit girlybubble

People would be happy and respectful.

Everyone would also own a cute fluffy bunny and give strangers a hug on the side walk.

This is not a fair world.

People like to steal your content

If that wasn’t bad enough, they don’t just copy your stuff, they link directly to it from your website.

The cheek!

This is called hotlinking and is very common-place with images.

People will add your image URL into their own web pages passing it off as their own.

As a double-whammy, this eats into your website’s bandwidth without giving you a whisper of SEO link juice.

Let’s get the gloves out and slap those hotlinkers across the face with our coding duel mitts.

Add the following code to the .htaccess file in the root of your WordPress installation.

[gist id=8143026 file=code-snippet-1.txt]

What does it do?

First things first.

On line 2 replace mysite\.com with your own domain name.

On line 4 replace /images/hotlinking-thief.jpg with the URL to the image you want to display if anyone tries to hotlink your images.

Be as creative as you can 😛

Lines 2-3 detect whether or not the requesting (incoming) URL is your own domain mysite.com (in this example).

Your own site needs to be able to display it’s pictures so happy days and do nothing.

If the URL contains another domain name then line 4 checks to see if it contains a request to display an image of types jpg, jpeg, gif, bmp or png.

If it does then we want to swap that image request with our own specific image URL.

So the hotlinker see’s our /images/hotlinking-thief.jpg on their site rather than the original image they were trying to steal.

Example: hotlinking-thief.jpg

Was this article helpful?
YesNo

One Response