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

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

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