×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

.htaccess

How can I avoid bandwidth theft? by danomac
Posted: 21 Mar 05 (Edited 17 May 05)

What is bandwidth theft?

Bandwidth theft occurs when others hotlink to files directly on your site, when you do not want them to. A common occurance for this is linking to your images, sound, or pdf files, as an example.

A common example is web forums. Most forums allow you to host avatars (these are small images that users can associate to their nicknames) directly on your website. When you do this, what's to stop the user from using the avatar on your server on other web forums?

How can I stop bandwidth theft?

Fortunately, you can use a .htaccess file to do this. Copy the example below into the directory where your images/documents are:

CODE

SetEnvIfNoCase Referer "^https?://(www\.)?example.com/" ok=1
SetEnvIfNoCase Referer "^$" ok=1
<FilesMatch "\.(gif|png|jpe?g)$">
   order allow,deny
   allow from env=ok
</FilesMatch>

All you need to do is change two things:

1. Change the 'example.com' above to your domain. Do not remove anything else though! The (www\.)? makes the www part optional in your domain name. As it is in the example, www.example.com and example.com will be allowed access.
2. Change the <FilesMatch "\.(gif|png|jpe?g)$"> if necessary. In the example, 3 common graphic formats are caught (note that both jpg and jpeg are caught.) As an example to add pdf files to the restriction use <FilesMatch "\.(gif|png|jpe?g|pdf)$">.

Save your .htaccess and it should work. The images will appear as a broken link in browsers.

Note: This will not stop someone from directly typing the URL in a browser! It has to be a link pointing to your website from another domain!

Back to Linux (server) FAQ Index
Back to Linux (server) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close