How to prevent image hotlinking

Well, the technical part is pretty easy – and just a quick Google search away. There are even online tools that give you the code you need.

The fun part is – what data do you send to the perpetrators. (UPDATE 04/2023: Here’s a very good post considering the implications of the various options.)

Now, it doesn’t seem like you can really do much harm. Yes, the obvious thing to do is to show an image that says “Please host your own images”. Some people may not even know how bad hotlinking is (for example, when you run a small VPS and you have to support a heavy traffic of several much larger websites). Sometimes, the people running a website don’t even know they are hotlinking; they just used a free WordPress theme that came with the offending code.

Well, in my case, I knew people had to go out of their way to get the images, so I thought I’d give them a bit of a lesson.

At first, I thought I’d redirect the traffic to a large file that would slow down their websites. It turns out it’s not easy to find a free image hosting that supports files over 900MB. Bummer.

So my second idea was to rickroll them.

This was fun and all, but then I wondered – can I do better? Is there a way to use my situation to make the world a better place? Of course!

#blacklivesmatter

More tutorials

A tinted, zoomed in screenshot of a JSON object showing server information about a Mastodon instance.
A tinted screenshot of two charts, one showing the popularity of various fediverse platforms (with Mastodon far ahead of the rest), and the other chart showing distribution of domain creation dates, mostly clustered around 2023.
A tinted screenshot showing the @mtaupdates Mastodon profile and a few example posts with subway status alerts.

💻 Browse all