How to Prevent People from Hot-Linking Your Contents

I am pro-hotlink. Some say hotlinking causes access flooding. That is true but in the day of broadband and terabite HDDs, I consider that obsolete. Hot-links gives the content providers the most precious asset: access log.

Still there are cases where you have to ban hot-links. Bandwidth? Copyright issues? Who knows except you?

So if you have to ban hot-links, try something like this if you are using Apache.

SetEnvIfNoCase Referer "^http://www\.dan\.co\.jp/" referer_ok
<FilesMatch ".(gif|png|jpe?g|mov|wmv|avi|flv)$">
  Order Allow,Deny
  Allow from env=referer_ok
</FilesMatch>

And you are all set. You'll see the picture below but you cannot hot-link it.

Remember, though, that referer validation is just skin-deep; It is really easy to forge referers. If you seriously want to ban hot-links, consider authentication and other measures.

Dan the Pro-hotlink