Show different image per ip address or user agent

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 7
Joined: 18 Oct 2012, 17:16

Show different image per ip address or user agent

28 Nov 2012, 05:28

here's my basic issue. There is a cluster of sites that have a single ip address that are hotlinking... I dont want to block all hotlinking images, but these guys are actually competitors of ours. They all are using the same bot user agent to I guess prefetch the images so it ends up residing on their site.

I want to serve them up an image based on their IP or user agent.

I have this currently in place.

RewriteCond %{HTTP_REFERER} ^http://(www\.)?example\.com(/.*)*$ [NC]
RewriteRule \.(jpeg|JPEG|jpe|JPE|jpg|JPG|gif|GIF)$ /hotlink2.png [L]

the user agent is QippoBot and the ip currently is 176.9.31.72
I'd love to serve up the hotlink image for anything in the 176.9.31.0-176.9.31.255 range.

Can that be done?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Show different image per ip address or user agent

28 Nov 2012, 18:15

Hello,

A correct way would be:

Code: Select all
RewriteCond %{REMOTE_ADDR} ^176\.9\.31\.\d{1,3}$
RewriteRule \.(jpeg|jpe|jpg|gif)$ /hotlink2.png [NC,L]


The NC-flag makes it case insensitive.

Regards
Andrew

User avatar
Posts: 24
Joined: 27 Nov 2012, 21:57

Re: Show different image per ip address or user agent

01 Dec 2012, 00:28

Case sensitive? You mean if it needs to be upper or lower, you should be certain of it? Thanks for this information.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Show different image per ip address or user agent

01 Dec 2012, 04:08

Here is the documentation regarding NC-flag.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 4 guests