# Example 1, block all hotlinking (when detectable) location ~* (\.png)$ { valid_referers blocked mysite.com www.mysite.com; if ($invalid_referer) { return 405; } } # Example 2, redirect hotlinked files only for some sites location ~* (\.mp4)$ { if ($http_referer ~ ^(http://www.bad.com|http://stupid.com) ) { # Redirect to a specific file #rewrite ^/(.*)$ http://mysite.com/dont-hotlink.html last; # Redirect to a dynamic url where /hotlinked/ is some script that # displays some info about the hotlinked file. rewrite ^/(.*)$ http://mysite.com/hotlinked/$1/ last; } }