Forum Moderators: phranque

Message Too Old, No Replies

Displaying "no hotlinking" image for specific referrer

         

lynnith

6:11 am on Sep 11, 2003 (gmt 0)

10+ Year Member



Alright, I've been browsing around and trying to compile my own .htaccess anti-hotlinking thingy, and sort-of failing. Here's what I have:

RewriteCond %{HTTP_REFERER} ^http://.*hotlinker\.com/ [NC]
RewriteRule .* /images/noway.gif [L,R]

All that does, however, is display nice red X's on the offending website. I would like for my no remote linking graphic to show up. Advice?

Thanks!

[edited by: lynnith at 6:46 am (utc) on Sep. 11, 2003]

closed

6:43 am on Sep 11, 2003 (gmt 0)

10+ Year Member



lynnith,

A few things:

1. Welcome to Webmaster World [webmasterworld.com].

2. You could have picked a more generic domain name to pick on.

3. Do you have this line in your .htaccess file? It's usually at or near the beginning:


RewriteEngine on

4. Your site's logs may give you more details on what you're doing wrong.

5. You may not really need the R attribute on your RewriteRule line, because the file is on your server.

lynnith

6:46 am on Sep 11, 2003 (gmt 0)

10+ Year Member



closed,

Thanks for the welcome!

Apologies for the non-generic-ness - pasted in without looking at it!

I do have the RewriteEngine on in there, and I also tried it without the R attribute and that didn't work either.

jdMorgan

6:58 am on Sep 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



lynnith,

You must have an image named "noway.gif" and it must be in subdirectory /images for the code to work as posted.

Also, this code was intended to be placed in the .htaccess file of a subdirectory containing only image files.
A safer "generic" version of the Rule might be:


RewriteRule \.(gif¦jpe?g)$ /noway.gif [L]

Note that the "¦" character above is modified by posting here. You must edit it and use the solid vertical pipe character from your keyboard - usually Shift-\

Do not use the [R] flag unless you have to. The client software can choose to ignore the rewrite if you use [R].

Jim

lynnith

7:14 am on Sep 11, 2003 (gmt 0)

10+ Year Member



Jim,

Thanks for the help - I modified my code to that and then realised that I had just put /images/ as opposed to the full path! That did the trick and now it's working great.