homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Is it possible to block hotlinking by an ip address?

 7:51 am on Nov 28, 2012 (gmt 0)

I have an issue with a particular bot that what it does is steal our images on the fly for several hundred websites that just happen to be competitors of ours.

I can block by the domain names, but what I'd really like to do is if this particular ip address or user agent comes along to only serve up another image file.


What I have been doing so far is to just block the ip addresses, but the number of sites this bot is "working for" is growing exponentially. I'd like to server them up an ad to come to our site LOL.

Here's what I have set up, but I need to block this with it's ip address or useragent since the domains change...

QippoBot is the user agent.

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



 10:02 am on Nov 28, 2012 (gmt 0)

Bookmark this page:


The variable you want is called REMOTE_ADDR, as in:

RewriteCond %{REMOTE_ADDR} ^123\.456\.789 [NC]
RewriteRule \.(jpe?g|gif|png)$ /hotlink.png [L,NC]

But remember that you only need to list those extensions that you actually use, unless you've got one of those case-insensitive servers. Do you really have image files named .jpg AND .JPG AND .jpe AND .jpeg and so on...?

CIDR ranges aren't very kind to Regular Expressions-- or vice versa-- so you may want to fudge it. For example if the offender lives at just say
without closing anchor, and to heck with anyone at 12.12.30.nn and .31.nn, or .48.nn and .49.nn. Unless they are particular friends of yours.


 3:26 am on Nov 29, 2012 (gmt 0)

Yea, I don't use .png files on our site.

Unfortunately some of the sales reps load files and yea the case and file types can be different. I generally clean it up a few times a year.

Thanks for the help Lucy!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved