OT Anyone know about .HT Access/Hotlinking ?

Stonefield wrote on 8/1/2005, 7:33 PM
I recently ran into a situation on my website were one of my videos was hotlinked to another site thus shooting my bandwidth ( way ) over it's alloted monthy limit.

My domain company suggested I use something called .HT Access to prevent any further unwanted hotlinking and letting me choose what sites have access to my videos.

Anyone know a good online tutorial where I can read up on this ? Did a Google, but not very successfully.

Stan

Comments

Chienworks wrote on 8/1/2005, 8:09 PM
This is a very sticky topic and not at all easy to deal with. Probably the best i can come up with for you is something that prevents people from fetching the files when surfers click a link to them in a page that isn't yours. You can create a .htaccess file in the same directory as the videos and insert the following commands:




where of course you put your own URL of the directory containing the videos and whatever file extension you normally use. This assumes that your web host is running Apache, has .htaccess enabled, and has mod_rewrite installed (quite often the case).

Note that this allows the files to be fetched either if the link is clicked on from your own page, or if the user has simply typed in the link rather than clicking on it. Many hotlinks will use a two-stage method whereby the first click launches media player and passes the URL on to it as a second stage. This means that media player thinks the link has been typed in rather tha clicked, so the web server will allow viewing the file anyway. Many of the non-mainstream media players and downloaders do the same thing as well. There are many other ways to overcome this method so it may not help much at all.

You could also set up user authentication in which surfers are asked for a username and password before being allowed to download. This is probably more restrictive than you would want since no one can download without knowing the password. Of course, you could post the password right on the download page, but then the people hotlinking will probably post the password on their page as well. You would probably end up with all of the hotlinking still happening and very few visitors to your own site viewing the videos. This is pretty much the opposite of the desired effect.

One very simple thing you can do, and i did this myself with vegasusers.com for a good long while, is to put the video files in a subdirectory with a random name, such as /woij3/video1.wmv and point the links there, then every few days change the directory name and the links to something different such as /jgi3l/video1.wmv. This means that any links people have posted become invalid the next time you change them. This is a lot of work if you have lots of videos, but it does get the job done pretty reliably. The nice thing is that if you can tell when the hotlinks start appearing, you can wait until then to make the changes, whether that be daily or monthly. On the other hand, if someone puts a hotlink in a very popular high-traffic place and you don't catch it right away, you can still suffer major downloads in a short period of time.

What i do now is use a script i've written to serve up the video files and encode a timestamp into the URL. This timestamp is only valid for a few minutes. If someone clicks the link after this time limit they get an alternate (and very very tiny) file that says 'external linking denied". The videos themselves are stored in a locked directory that only the script can read. The script also tracks IP addresses and blocks them if there are too many accesses from the same IP address range in a certain time period. This seems to be about as foolproof as one can get. Unfortunately it requires CGI access on your server and the ability to set up locked directories.

I would be more than happy to give you a copy of the script and other instructions if your web host is willing to allow it.

references:
http://httpd.apache.org/docs/2.0/howto/htaccess.html
http://httpd.apache.org/docs/2.1/howto/auth.html
http://httpd.apache.org/docs/2.1/rewrite/rewrite_guide.html
Stonefield wrote on 8/1/2005, 8:25 PM
Thanks Kelly this is great...

Yeah, when I last spoke with my webhost, we talked about Apache, .htaccess and mod_rewrite. From what I gather, my site as all of these. They also said it's possible to give a list of websites that are allowed to hotlink based on my own permissions.

For what it's worth, the offending video was, oddly enough, the infamous KISS video. I've since took it off my site.

I'm gonna talk with my webdesigner, hosting company and look thru your response here in the next day or so.

Once again, thanks for this....

Stan
Spot|DSE wrote on 8/1/2005, 8:56 PM
Thanks for the info Kelly, and for bringing this up, Stan. We ran across this on one of our small sites, and our ISP was basically wanting to charge us $$ for fixing this, but Kelly's post provides me some ammo to talk to them.
Stonefield wrote on 8/2/2005, 12:52 AM
I hear ya Douglas.

Well, what actually happened is while I was on vacation at the beginning of July, it seems that around the 6th of that month, someone somewhere put a direct link to my KISS video to a "guys" site. Not really a porn site but more like a Maxim, FHM magazine feel. Basically a girly site. I did some digging and looking at my webstats and found the link ( which was also linked to a couple of sites in Japan ! ). I checked the stats of my bandwidth so far for the month. This was in the middle of July.

I'm allowed 50 gigs of traffic per month and I rarely, if ever, go over 10. Well within a 48 hour period after that video was hotlinked, my site's traffic surpassed my 50 gigs I pay for and went up to over 900 GIGS !!!

I immediately deleted the video, and the next day called my hosting company to discuss this. They had to think about what to do as this was such a unique situation. They had my stats for the last couple years so it was obvious that this was not my fault. But...they did closed me down until Aug. 1st and agreed not to charge me for the extra bandwidth. If they would have, I would have owed them over $6500 !!!

So luckily I have a good relationship with my hosting company and they worked with me on this. It was they who told me about the htaccess and I also now told them to NOT let me go over my alloted monthly traffic.

Whew, huge learning experience....hope you guys don't have any similar troubles.

Stan

PS When I start producing stock media for sale on the site, I hope I get similar results......heh. ( well not THAT much )