Preventive File Downloads from Other Sites

Discussion in 'Site & Server Administration' started by dpakman91, Apr 8, 2006.

  1. #1
    I have a fairly extensive video page on one of my sites. Naturally, i don't like direct linking to videos from other sites, but in the past i haven't cared.

    lately it's been more and more bandwidth that been eaten up by direct downloads from other sites...

    How can i prevent it? I imagine there are many ways to do this, from embedding the files, to some kind of referrer block or something, but i really don't know anything about it. what's my simplest, best bet?
     
    dpakman91, Apr 8, 2006 IP
  2. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #2
    In .htaccess:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^[url]http://([/url][^/]+\.)?yoursite\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule \.(avi|mpg|mpeg|wmv)$ getlost.jpg [L]
    </IfModule>
    Code (markup):
    There's more information about stopping hotlinking in this article that I wrote.

    Although it's about images, it can be applied to any file type. There's also a php script in there that could be modified to handle other file types and send an email alert every time anyone tries hotlinking a file.
     
    ryan_uk, Apr 8, 2006 IP