ServersKeeping Your Images from Adorning Other Sites Page 4

Keeping Your Images from Adorning Other Sites Page 4

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

If you’re not sure whether anyone is really after your artwork,
you can use the same detection mechanism and envariable to
log suspicious requests. For instance, if you add the following
directives to your httpd.conf file, an entry will
be made in the /usr/local/web/apache/logs/poachers_log
file any time someone accesses one of your images without a valid

    SetEnvIfNoCase Referer      !"^" not_local_ref=1
    SetEnvIfNoCase Request_URI  ".(gif|jpg)"               is_image=1
    RewriteEngine  On
    RewriteCond    $ {ENV:not_local_ref} =1
    RewriteCond    $ {ENV:is_image}      =1
    RewriteRule    .*                   -     [Last,Env=poach_attempt:1]
    CustomLog logs/poachers_log         CLF   env=poach_attempt

This should have the effect of logging all attempts to access
your images using one of the potential 'snitching' techniques
described in this article. The first two lines set flags for
the conditions (that it's an image, and that it was't referred
by a local document), the RewriteCond lines check
to see if the flags are set, the RewriteRule line
sets a third flag combining the two, and the last line causes the
logging of the request in a special file if that last flag is
set. The log entry is written in the pre-defined 'CLF' format
('Common Log Format'), but you could put together your own
format just as easily.

Other Resources

The techniques described in this article are geared toward a single purpose,
but illustrate some of the capabilities of the Apache server.
Here are some pointers to resources for further investigation:

  • The HTTP/1.1 definition document:>
  • The main Apache Web site, of course:>
  • The documentation for Apache and its modules:>
  • The canonical email response page:>

    (This page is normally used to respond to email requests for
    support, but there are lots of good resources listed on

Then there are the specific pieces of the Apache documentation that are
directly related to the directives and commands described in this

  • The documentation for documentation:>
  • The mod_setenvif documentation:>
  • The mod_access documentation:>
  • The mod_rewrite documentation:>
  • The documentation on the CustomLog directive:>


Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories