lucy24 - 11:30 am on Mar 16, 2013 (gmt 0)
Here's yet another detail I didn't notice earlier. Thanks to one of those heart-stopping moments when you're doing routine testing and you think your entire htaccess has stopped working...
Coincidentally this is the same rule I started out with. The pattern, unanchored, is
further constrained to image files (jpe?g|gif|png).
Outside the <Files> envelope, this would not only work for
(nonexistent files and/or directories-- so long as they fit the regex)
Inside the envelope the rule will still work for made-up filenames-- but not for paths involving nonexistent directories. This seems paradoxical since the envelope is called <FilesMatch> ... but it makes sense if you think of mod_rewrite continuing its search all the way to the document's home directory. It has to make sure that the current rule will not be superseded by subsequent RewriteRules. So it doesn't matter whether the file does exist, only that it can exist.
This, in turn, means that unwanted visitors asking for nonexistent files may end up with a 404 where they would otherwise have been whacked with an unconditional 403. Hm. With some robots, this may actually help. "You can't have it!" is a challenge. "It ain't here" leaves nothing more to say.