I have been asked this question a few times recently so I have decided to do up this post to help out everyone.
Protecting your content with htaccess files is standard practice for most website owners, whether it be for protecting a members area or just stopping hotlinking and saving your bandwidth. But normal htaccess files will not protect movie files because when a surfer clicks a movie file, their computer launches a new application (windows media player, quick time player, etc), and this new application that requests the movie file without any referral data, which htaccess protection relies on to work.
The way around this problem is to use cookies. Briefly, you set a cookie on your gallery page and then check for that cookie in an htaccess file in your movie directory.
NOTE: if your surfer has cookies turned off or is not allowing them, they won't be able to get your movies
Here is exactly how to do this:
1) On your gallery page, use this code to set a cookie on the surfer's pc. Add this javascript to the <head> section of the document containing the links to your videos.
Code:
*SCRIPT language="JavaScript">
document.cookie = "id=valid; path=/"
*/SCRIPT>
note - I could not post this code properly so you have to replace the two * with <
2) Put your videos into a separate directory. Nothing else goes in this directory except this .htaccess file:
Code:
RewriteEngine on
RewriteCond %{HTTP_COOKIE} !(^|(.+;)*)id=valid(;.*|$)
RewriteRule .*$ http://www.yourdomain.com/cheaters.html
And just replace yourdomain.com/cheaters.html with the appropriate URL.
Hope this helps,
cheers!
Luke
Bookmarks