Help tweak this .htaccess code Help tweak this .htaccess code
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Help tweak this .htaccess code

Started by nontekkyguy, April 23, 2006, 01:31:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nontekkyguy

I am using .htaccess in addition to certain permission settings to control how visitors access my gallery. Here is one line I tried which points to an image on my server.  I use the following code:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?josefaro\.org[NC]
RewriteRule .*\.(zip|mp3|avi|wmv|mpg|mpeg)$ http://www.josefaro.org/images/fisheyedfool.jpg [R,NC,L]
</ifModule>


to stop that pesky hotlinking business. Does anyone see any way to enhance this code. So far it doesn't seem to work in every case. In fact I'm able to go to properties of the enlarged image, grab the location link, post it in a forum and see the image.
learning requires patience; teaching requires more

Stramm

this will only work for image files... cause media player doesn't send a referer header. For movies you'll need to use another attempt

scripts like these possibly may protect you
http://www.antihotlinking.com
http://www.trafficguardian.com/hotlink/anti-hotlink.html

or you may force users to visit a html page before you let apache serve the content using a cookie

this htaccess needs to go in your content directory (where your movies are, no html, php in there please)
RewriteEngine on
RewriteCond %{HTTP_COOKIE} !(^|(.+;)*)id=valid(;.*|$)
RewriteRule .*$ http://www.yourdomain.com/hotlinking.html


on the html, php where you link to the content you need to set the cookie eg with something like)

<SCRIPT language="JavaScript">
  document.cookie = "id=valid; path=/"
</SCRIPT>


I haven't tried for coppermine... but it should be enough to put
  document.cookie = "id=valid; path=/"
into scripts.js