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

  • 3 weeks 6 days ago
  • 3 weeks 6 days ago
  • 1 month 19 min ago
    php 8.x
  • 1 month 1 day ago
    10.6.7
  • 1 month 2 days ago
    Drop Centos 5/6 stuff