:: further bump ::
Well, I took the plunge and added a <FilesMatch> envelope for
images only:
<FilesMatch "\.(jpe?g|gif|png)$">
The contents of the envelope turned out to be evenly split between [F] and [L]. No redirects. I put the envelope in front of the general RewriteRules, though I'm pretty sure it doesn't matter, since it is read separately.
And now I have two head-scratchers.
#1 I was under the impression that <Files> applied only to real files that physically exist. -f kind of thing. And also that any rules inside an envelope are
in addition to, not instead of, any rules outside the envelope. So I left a final trio of rewrites on the outside:
RewriteRule smallgifs/dot\d+\.png /pictures/smallgifs/onedot.png [L]
RewriteRule smallgifs/dot[\w-]+\.gif /pictures/smallgifs/onedot.gif [L]
RewriteRule smallgifs/dot7$ /pictures/smallgifs/onedot.gif [L]
This did not work. The rewrites didn't take place, and requests returned a 404 instead. To make the rewrites happen, I had to put them inside the FilesMatch envelope. Where they match against... uh... nothing, but nevertheless get rewritten as intended.
On the other hand, a group of image redirects that I left out of the envelope-- again because the requested files don't exist-- take place perfectly well. It's only the rewrite that plays dead.
#2 Continuing from #1: If I ask for
example.com/pictures/smallgifs/dot[\w-]+\.gif
using the "wrong" form of the domain name, the request doesn't get picked up by the canonicalization redirect. (Obviously this will only happen when I'm typing an URL straight into the address bar, but the RewriteRule doesn't know that.) Putting a duplicate of the canonicalization redirect into the middle of the envelope is not the solution; this results in a request for
www.example.com//home/lucy24/example.com/pictures/smallgifs/dot_j1.gif
-- the form you'd get if your rewrites and redirects were happening in the wrong order. (Note the two slashes. The first one is from the text of the rule; the second is from the capture.) Except that the rewrite obviously hasn't happened yet, or I'd be seeing "onedot.gif" at the end. In fact the rewrite aspect is a red herring, because the same thing happens if I request any image file with the wrong domain name. But everything comes through perfectly well if the request has the right name.
I am puzzled.
:: wandering off to deal with unrelated but equally worrying question of how g### has contrived to crawl a page which, to the best of my knowledge, has no links to it anywhere in the universe, and will not be crawl-ready for another week at least ::