Disallowing Remote Linking of your Files
If you have binaries, music, or other large files on your website and do not want people to link directly to them, this is what you have been looking for. People who link to your files are using your bandwidth to transmit them to their web site viewers, and if the bandwidth usage is enough it will increase your overall costs for hosting (which is not good if that is not what you intend).
Remember to upload .htaccess files, and .htpasswd files using ASCII mode. This is an option is available in most FTP clients.
Contents
What follows is an example .htaccess file set of commands to limit the downloading of zip and jpg files. The user "John" is hosting them on "JohnSite.com", and alternatively "john.darkscape.net".
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://johnsite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.johnsite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://john.darkscape.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.john.darkscape.net/.*$ [NC]
RewriteRule .*.(zip|jpg)$ - [NC,F]
Returning another image in place of the remotely linked image.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain.com/.*$ [NC]
RewriteRule .*.(gif|GIF|jpg|JPG)$ http://your_server.com/bad.gif [R]
* NC stands for no case