Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Is it possible to block hotlinking by an ip address?


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


Bookmark this page:

[httpd.apache.org...]

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 12.12.32.0/20 just say
^12\.12\.[34]\d\.
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.


Thread source:: http://www.webmasterworld.com/apache/4523123.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com