homepage Welcome to WebmasterWorld Guest from 54.163.70.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess, hotlinking, no mod_rewrite
Ernos




msg:1524745
 8:14 pm on Jul 5, 2003 (gmt 0)

First, I know this topic has been covered many times in your forum. I have used your search engine (and Google) to try and answer my question for myself before bugging you guys about it, but I can't seem to find anything that specifically tells me what I'm trying to find out, so I hope you'll be gentle with me!

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




msg:1524746
 8:57 pm on Jul 5, 2003 (gmt 0)

I believe this is what your looking for?
SetEnvIf directive
[httpd.apache.org...]


Ernos




msg:1524747
 9:06 pm on Jul 5, 2003 (gmt 0)

Er. Well. Yeah, that's some documentation about setenvif...But like I said, I'm a newbie when it comes to these things, and while I'm trying to read up on this as much as possible, I'm having a hard time finding a practical solution to my question. Thank you for the link, though.

wilderness




msg:1524748
 9:27 pm on Jul 5, 2003 (gmt 0)

Scroll down to the section heading:
SetEnvIf directive

Which provides an example of EXACTLY what you desire.

claus




msg:1524749
 9:46 pm on Jul 5, 2003 (gmt 0)

welcome to WebmasterWorld Ernos :)

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

Ernos




msg:1524750
 10:03 pm on Jul 5, 2003 (gmt 0)

I too would appreciate an explanation or a more detailed example...I did read the part about SetEnvIf, but the example provided on the page eluded me as far as how I should alter it to fit my own .htaccess file.

Thanks for your patience, all. :)

wilderness




msg:1524751
 5:50 am on Jul 6, 2003 (gmt 0)

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?

jdMorgan




msg:1524752
 11:14 pm on Jul 6, 2003 (gmt 0)

AFAIK, you can deny hotlinkers without mod_rewrite, but you can't feed 'em an alternate image, unless you want to write a script to do it.

Jim

claus




msg:1524753
 11:15 pm on Jul 6, 2003 (gmt 0)

I've been researching this. It does not seem like you can do it with SetEnvIf alone. If you have the module "mod_mime" available, however, there is a way that does not involve "mod_rewrite". Unfortunately this workaround also implies that you have to write a small script in some language that:

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved