how to block hotlinking for my media files?

I have swf& images files that can be hotlinked from otherwebsites like in this question How can I use HTTP Referer header to have my swf files viewed only from my website ?


My files are hosted at my server, I am not using Amazon S3 service, or other files hosting services.


if request.env['HTTP_REFERER'] =~ /yourdomain\.com\//
  # serve asset

Note that nil =~ regex # => nil so you don't need to check if request.env['HTTP_REFERER'] exists first.


More about the =~ operator: Object#=~, String#=~, Regex#=~

$ irb
> nil =~ /something/
=> nil

You should assure that referrer link has same domain as yours, like if you have nginx:

location ~* (\.swf)$ {
    valid_referers blocked;
    if ($invalid_referer) ) {
        return 444;

Need Your Help

Binary Converter For Loop Trouble

javascript string for-loop binary converter

So I am making a binary converter for science project and I am having a bit of difficulty.