I'm quite sure this has been asked before but I can't for the life of me find anything.
A client of mine has a number of pages that we closed to the public today. Because image URLs associated with those pages are still valid (the pages must continue to be visible internally for maintenance), the page is obviously still fully visible from the Google cache, which understandably annoys my client.
I would like to fix this using a mod_rewrite directive, 403'ing or 404'ing any requests to that image directory that do not have a REFERER that starts with that site's domain (i.e. are hotlinked to by the pages in the cache).
Update: This works for me!
RewriteCond %{REQUEST_URI} ^/imagedir
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.com [NC]
RewriteRule .* - [F,L]