Forum Moderators: phranque
My hosting company refuses to support mod_rewrite, so I've had to prevent hotlinking by using SetEnvIfNocase. Currently, this is my .htaccess file:
SetEnvIfNoCase Referer "^http://mydomain.com(/¦$)" allowed=1
SetEnvIfNoCase Referer "^http://www.mydomain.com(/¦$)" allowed=1
SetEnvIfNoCase Referer "^$" allowed=1
Order Allow,Deny
Allow from env=allowed
This works great, it's very simple (I'm very much a newbie when it comes to these things) so no issues there. However, I was hoping there was some way I could not only prevent hotlinking, but actually show an alternate graphic (like an image that says "Hotlinking makes Baby Jesus cry") in its place if someone tries it. Without mod-rewrite, is this possible?
Thanks in advance for anything you can tell me.
wilderness, i didn't think that you could accomplish this with SetEnvIf alone, so i'm curious:
From the example you point to: Is it this line that would provide an alternate graphic, and which graphic would it be then? - could you explain, i don't understand it?
SetEnvIf object_is_image xbm XBIT_PROCESSING=1
/claus
Is it this line that would provide an alternate graphic, and which graphic would it be then? - could you explain, i don't understand it?SetEnvIf object_is_image xbm XBIT_PROCESSING=1
I believe so claus.
I've never used this method, since my webhost has most evey module you can imagine loaded up.
Perhaps Jim or Andrea can expand on it?
a) accepts all requests for all image files,
b) evaluates if the recipient is allowed to get it, and
c) serves it if yes, or
d) serves an alternative if no
I have found a nice and simple example using php, but you can also use perl, or whatever you prefer. Send me a sticky if you would like to get the URL - i have noticed that posting an URL here at WW can have some un-intended sideeffects on servers not geared toward heavy load...
Here's the .htaccess part of the equation:
Action image-parser /path-to/parser.php<FilesMatch "\.(jpe?g¦png¦gif)$">
SetHandler image-parser
</FilesMatch>
The code does this:
a) declares a handler called "image-parser" and sets it to the path mentioned
b) checks for requests for ".jpg, .jpeg, .png, .gif"
c) when such requests come in, they are delivered to the handler "image-parser" (ie: the php-script)
All the checking for referrals etc is then done by the "parser.php" script. This script does a,b,c,d as explained above.
/claus