Forum Moderators: phranque

Message Too Old, No Replies

Preventing a single referrer from hotlinking

         

guillermo5000

11:03 am on Apr 3, 2004 (gmt 0)

10+ Year Member



I have a site that is hotlinking to my pictures. I know how to completely block them from doing this, but what I want to do is serve up a different picture only to that referrer. I have been reading apache's reg. expression information and struggling with this for some time with no success.

Any help is appreciated.

jdMorgan

11:40 pm on Apr 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



guillermo5000,

Try this search [google.com].

Jim

guillermo5000

12:38 am on Apr 6, 2004 (gmt 0)

10+ Year Member



Thank you! It seems to be working now.

My first try created an infinite loop since I watched for this referrer to request a jpg and then served them up the same type of file that they were not allowed. Oops! For others that might read this, always use a different type of file for the 'special' image your going to let the hotlinker see, such as png or jpe.

I also discovered that using [OR] on the last RewriteCond (never correct) caused ANY request for a jpg to be rewritten to the 'special' jpg. Also oops!

Anyhow, thank you for steering me in the right direction.

jdMorgan

12:59 am on Apr 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can prevent the loop by excluding redirection if the requested image is the replacement image:

RewriteCond %{REQUEST_URI} !^/special_image\.jpg$
RewriteRule \.(jpe?g¦gif¦png)$ /special_image.jpg [L]

Jim