The ftp://ftp.apache.org/apache/dist/contrib/modules/mod_block.c module blocks access to pages based on the referer field. This helps prevent (for example) your images being used on other people's pages.
For more complex cases, http://www.engelschall.com/~rse/ implements blocking based on arbitrary headers (e.g., referer and user-agent), as well as on the URL itself.
Copyright © 2001 O'Reilly & Associates. All rights reserved.