Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Help tweak this .htaccess code  (Read 4667 times)

0 Members and 1 Guest are viewing this topic.

nontekkyguy

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 59
Help tweak this .htaccess code
« on: April 23, 2006, 01:31:30 pm »

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:

Code: [Select]
<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.
Logged
learning requires patience; teaching requires more

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Help tweak this .htaccess code
« Reply #1 on: April 23, 2006, 02:20:33 pm »

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)
Code: [Select]
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)
Code: [Select]
<SCRIPT language="JavaScript">
  document.cookie = "id=valid; path=/"
</SCRIPT>

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

Pages: [1]   Go Up
 

Page created in 0.015 seconds with 19 queries.