Make Homepage | Add To Favorites | Print Page | Submit News | Feedback | Contact | 

Your Technical Computer Information Resource!  
     
  Prevent people from linking to your files on their web pages (Apache)  
TACKtech Corp. > Articles > Software > Web Page Editing and Hosting

Prevent people from linking to your files on their web pages (Apache) (TTID #67)

Author: Travis   Views: 17,113 /  Created: August 22, 2001
Problem:
Other sites may be accessing files such as graphics directly from your site. If your payments to your web hosting provider is based on bandwidth usage you are paying to support someone else's web site. This also places additional load on your server.

Solution
You can help prevent other web developers from doing this by using Mod Rewrite since most Internet browsers send the referring page along with the image request. This set of rules simply reports the files as being "gone", creating a broken link on the browser.

Instructions:
NOTE: In order to use this feature of the Apache Server, you must make sure that the server was installed with the mod_rewrite.o file. This is done by adding the line to the Configuration file before compiling the server. AddModule modules/standard/mod_rewrite.o

Create a .htaccess file in the file directory you wish to protect. This set of rules basically looks at the domain name provided by the HTTP_REFERRER (from the beginning) without regard to upper or lower case. (NC means No Case). Do not use F for forbidden if you are using ErrorDocument redirects.

You can do this to protect files types such as WAV, MP3, MIDI, GIF, and/or JPG files by changing the TTT to the extension you would like to protect. Of course, be sure to change yourdomain.com to whatever your domain happens to be!

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
RewriteRule .*\TTT $ [L]


Note: This does not prevent people from right-clicking and saving images on your pages.

Your Name:


Your E-Mail: (required)


Friend's E-Mail: (required)




View Our World Wide Web Customer Privacy Policy
  Featured Articles  
  Quick Links  
  Top Affiliates  
........