Print

Print


Hi Eric

I'm a little rusty on Apache's Rewrite rules, but here's what I've got
set up in a .htaccess file (see
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html):

    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://216.239.*/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://216.239.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://66.102.9.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://66.102.7.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^.*melanson.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^.*mindjack.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^.*google.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://daveyp.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://daveyp.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.daveyp.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://localhost/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.daveyp.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^.*gordian.*$      [NC]
    RewriteRule (.*)\.(jpg)$ http://www.daveyp.com/cgi-bin/no.pl?$1.$2
[R,NC]

The gist of the above is:

1) if no HTTP_REFERER string is sent (!^$), then allow them to see the
image
2) if any of the remaining RewriteCond's match the HTTP_REFERER, then
allow them to see them image
3) otherwise if the user is asking for a .jpg file, perform the
RewriteRule

I've used a Perl script (no.pl) to decide which image to send to the
user, but you could easily use something like the following to redirect
to a static image file:

    RewriteRule (.*)\.(jpg)$ http://www.daveyp.com/no.png [R,NC]

Basically, my site is daveyp.com so that's a valid HTTP_REFERER and the
others are sites that I'm happy to use my images.

I'm no expert on Rewrites, so there might be an easier way of doing it.

Hope that helps!
Dave


> -----Original Message-----
> From: Code for Libraries [mailto:[log in to unmask]] On
> Behalf Of Eric Lease Morgan
> Sent: 31 March 2006 13:59
> To: [log in to unmask]
> Subject: Re: [CODE4LIB] external linking to your images
>
>
> On Mar 31, 2006, at 7:37 AM, David Pattern wrote:
>
> > If I were you, I'd replace your "first home" picture with
> one showing
> > a condemned property....
>
> I thought of this but I also thought it might be sort of rude
> on my part.
>
>
> > If you have admin access, then you can usually set up rules
> to limit
> > which referring sites can directly use your images.
>
> Can you ore someone else here on this list be more specific
> about rules and referring sites? How do I configure Apache to
> do such a thing? Maybe I could get trickier and redirect such
> links to a donation page, or I could authorize certain links
> and not others, but now it is probably getting more
> complicated than it needs to be.
>
> --
> Eric Morgan
>

This transmission is confidential and may be legally privileged. If you receive it in
error, please notify us immediately by e-mail and remove it from your system. If
the content of this e-mail does not relate to the business of the University of
Huddersfield, then we do not endorse it and will accept no liability.