How to prevent downloading and leeching media files


Hits: 14664  

How Do I Stop Hotlinking, Bandwidth Theft, Downloading and Leeching media files?

You can stop downloading / hotlinking / leeching your site’s files using .htaccess in your Apache root or directory. The Apache mod_rewrite must be enabled for this.

The 1st line of the above code begins the rewrite. The 2nd line matches any requests from svnlabs.com url. The [NC] code means “No Case”, meaning match the url is not case sensitive. The last line matches any files ending with the extension pdf|zip|gif|jpg|dmg|flv|mp4|mp3|rar have blocked access or 403 error.

Please find more media file extensions here…

You can see access is blocked for some files other are showing here….

Files on FTP….

Here is demo for JWPlayer…

Even you can download files any case you can play that file because it content below code 😉

We you try to download media file it will show following access error…

You can block some traffic using server’s firewalls 😉

Check your URL, if you see your media load, your media can be hotlinked.

There are actually quite a few reasons to use .htaccess

1. Make URLs cleaner and easier to remember for visitors.
2. Make dynamic pages appear as static for SEO.
3. Security / Protection for PHP sites.
4. Sub-Domain managements……

Demo: How to protect file leeching

The best and most practical way to stop theft is to use a streaming server like Red5, Wowza, FMS etc. HTTP Streaming is very insecure but RTMP / RTSP are best on streaming server 😉

Time is nature’s way of making sure that everything doesn’t happen at once. Space is nature’s way of making sure that everything doesn’t happen to you.

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch

  • Sandeep Verma

    True guidance can b like a small Lamp in a tunnel.

  • Voratinklis

    Before deleting comment please explain why with this preventing metod i still can download working video file.

  • Anonymous

    I agree you can download video file… but try to play same file in desktop based media player

  • Anonymous
  • Anonymous
  • Voratinklis

    Look at this:

    As You see – file size is correct ant after downloading it`s normal working video file

  • Anonymous

    I am downloading BS Player to see this action 😉

  • Anonymous

    Yes, I just checked the behavior of .htaccess is strange in different browsers… but I will fix this in few days 

    http://perishablepress.com/press/2007/11/21/creating-the-ultimate-htaccess-anti-hotlinking-strategy/ 

    Thanks Voratinklis  

  • Anonymous

    Yes, I just checked the behavior of .htaccess is strange in different browsers… but I will fix this in few days 

    http://perishablepress.com/press/2007/11/21/creating-the-ultimate-htaccess-anti-hotlinking-strategy/ 

    Thanks Voratinklis  

  • Shane

    Yes, this does not work.

  • krishnakumar

    when i press ctrl + s or save page as… video will be download… i want to prevent that from save page…

  • tarun123

    Hi, There are securities for businesses to prevent video downloads. Akamai DRM is the leader in this but it is too costly . You can try vdocipher.com . They use some encryption technology to prevent video download. No downloader is able to catch them.

  • Andrey

    http://www.svnlabs.com/leeching/file/raaga.mp4 right clck, download, now you can see video from your PC.

    so you can’t prevent me from downloading.