views:

13

answers:

1

I believe someone is scraping images from my site. So what I want to do is, based on their specific IP address, serve up some kind of holding image instead of the actual image.

How do I achieve this using .htaccess?

A: 

Try this mod_rewrite rule:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} =12.34.56.78
RewriteRule !^images/foobar\.png$ images/foobar.png

This rule will rewrite any request from the IP address 12.34.56.78 that is not /images/foobar.png internally to /images/foobar.png.

Gumbo
Great thanks, can I make it redirect to a file thats not internal to my server? I.e. CDN etc?
Chris
@Chris: Just replace the relative URL by an absolute URL and add the [‍*R* flag](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteflags) if necessary.
Gumbo