Stop image bandwidth theft

Prevent other websites from stealing your bandwidth by including your images in their pages.

  • Apache
    This example services up a different image instead:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} ^http://.*$
    RewriteRule \.(jpe?g|gif|bmp|png)$ /media/nohotlinks.png [L]
  • Lighttpd
    $HTTP["referer"] !~ "^(http://example\.com|http://www\.example\.com)" {
      $HTTP["referer"] != "" {
        url.access-deny = ( ".jpg", ".jpeg", ".png", ".gif", ".pdf" )
      }
    }

    Includes a remote IP option if you have certain IP's you want to be able to get at the images:

    $HTTP["referer"] !~ "^(http://example\.com|http://www\.example\.com)" {
      $HTTP["remoteip"] !~ "^(127\.0\.0\.1)$" {
        url.access-deny = ( ".jpg", ".jpeg", ".png", ".gif", ".pdf" )
      }
    }
  • Varnish
    Varnish rules to server a result quicker?

    Resources
    Bandwidth Theft | Preventing image hotlinking with .htaccess
    Smarter Image Hotlinking Prevention
    Using Varnish to capitalize on image hotlinkers and retain referred visitors

Recent Updates

  • 2 years 2 days ago
  • 2 years 2 days ago
  • 2 years 4 days ago
    php 8.x
  • 2 years 5 days ago
    10.6.7
  • 2 years 1 week ago
    Drop Centos 5/6 stuff