BF50 Black Friday · 50% off all plans
from $5/mo · Auto-applied ---:--:-- Claim 50% off →
Skip to content

Search Seonio

Type a keyword, domain, or paste a URL

Start free with $1 to see full results. Powered by Seonio
Web Development

Hotlinking: What it is and how to stop it

Hotlinking is when another site shows your image or file by loading it straight from your server: they get the content, you pay for the bandwidth.

Monthly searches · hotlinking
74.0k
Keyword research data
hotlinking
Hotlinking: What it is and how to stop it
Click the image to view it full size

On a normal page, every image comes from the site's own server. A hotlinked image doesn't. Another site puts the address of your file into its own HTML:

<img src="https://yourshop.com/images/trail-shoe.jpg" alt="Trail shoe">

Each time someone opens their page, the visitor's browser asks your server for the image. You serve the file and pay for the traffic. Their page looks complete, and the visitor never comes to your site. People also call it inline linking or, less kindly, bandwidth theft. It works for any file: images most often, but also videos, PDFs, fonts and downloads.

Loading files from your own subdomain or CDN is not hotlinking. That's your own content, served from somewhere you chose.

Why it's worth stopping

  • You pay for someone else's page. One popular forum thread or scraper site can send thousands of requests for your files. On hosting with a traffic limit, that comes out of your allowance.
  • Your work appears out of context. Your product photo might sit next to a competitor's prices, or your chart in an article you'd never stand behind.
  • You don't get the visit. The image does the work on their page; the reader has no reason to click through to yours.

A few hotlinked images rarely matter. It's worth acting when your server logs or bills show a lot of image traffic coming from pages that aren't yours.

How your server can tell

When a browser loads an image for a page, it usually sends a Referer header: the address of the page that wants the file. By default, browsers send only the other site's origin on cross-site requests, such as https://othersite.example/, but that's enough to see that the request isn't for one of your pages. MDN

So hotlink protection works by checking that header and refusing image requests that come from other sites. Two limits to know before you set it up:

  • Some honest requests have no Referer. Someone who opens the image's address directly, a privacy setting or an app may send none. If you block empty Referers, you block real visitors.
  • The header is easy to fake. Referer checks stop ordinary browsers showing your files on other sites. They don't stop someone determined to download them.

How to block hotlinking

On Apache

This rule, from Apache's own documentation, goes in an .htaccess file or the server configuration. It refuses image requests whose Referer is present but isn't your site, and lets empty Referers through: Apache HTTP Server

RewriteEngine On
RewriteCond "%{HTTP_REFERER}" "!^$"
RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
RewriteCond "%{HTTP_REFERER}" "!\.google\." [NC]
RewriteRule "\.(gif|jpg|png)$" "-" [F,NC]

Replace www.example.com with your domain and add the file types you serve, such as webp or avif. The third condition isn't in Apache's example: it leaves requests from Google alone, so the full-size preview in Google Images keeps working (more on that below). Instead of refusing ([F]), you can send a replacement image that says where the original lives.

On nginx

nginx has a valid_referers directive for the same job. Its documentation example allows requests with no Referer, your own server names and Google, and refuses the rest: nginx

valid_referers none blocked server_names ~\.google\.;
if ($invalid_referer) {
    return 403;
}

On a CDN

If your images come through a CDN, block hotlinking there, since requests may never reach your own server. Many CDNs have a referer or hotlink setting; check your provider's documentation.

With a response header

The Cross-Origin-Resource-Policy: same-site header tells browsers that support it not to load the file into pages on other sites. It's simple, but it's all or nothing: it also blocks every site you might want to allow.

Don't block Google Images by accident

When someone opens your image in Google Images, Google shows the full-size picture by loading it from your server, with a Google address in the Referer. A rule that only allows your own domain also stops that preview.

If you want the full-size preview, allow Google's domains, as both examples above do. If you'd rather not, Google documents a clean opt-out: answer image requests from Google domains with a 200 or 204 status and no content. Google keeps crawling your page and shows a thumbnail it made at crawl time instead, and doesn't treat this as cloaking. Google Search Central Either way, decide on purpose: images are part of your image SEO.

If you want to use someone else's image

Ask for permission and host a copy on your own server, or use the embed code the site offers. Hotlinking also leaves your page at the mercy of theirs: when they rename the file or add protection, your image breaks or turns into their replacement.

Seonio

Put it to work on your own site

Keyword research, traffic, backlinks and clustering in one place. Start with a free $1 to test, no card required.