lucy24 - 3:16 am on Mar 13, 2013 (gmt 0)
The issue applies to everything inside the envelope.
Say I put an exact copy of the domain-name-canonicalization rule inside the envelope-- something you ordinarily wouldn't need to do, since image requests come from pages, and therefore already have the correct form. The pattern is the ultra-generic unanchored (.*) the kind that makes people foam at the mouth in all other circumstances. If I then request an image file with the wrong domain name-- after disabling the lines that deal with referer-less requests, duh-- I end up with
Note double slash, because the leading slash in "/home" was captured.
I think there has to be something about the envelope itself that's doing it. Normally you wouldn't notice, since Files(Match) envelopes almost by definition look at the end of the filename. And generally the envelope is for things like access and authorization that don't pertain to the requests. As noted elsewhere, I've already learned that in spite of the name, Files doesn't only apply to physical files. It also applies to requests.
I also think that the envelope has two effects. It makes things run faster for non-image requests, since the server doesn't even have to stop and read the rule. But I suspect it makes things slower for image requests, exactly as if they had to pass through two full htaccess files. Execution of any RewriteRules is put on hold until the request has passed through the inner envelope.
I tested that part like this:
RewriteRule dunnykin http://www.example.com/hoosegow/test-two.html [R=301,L]
RewriteRule .+ http://www.example.com/hoosegow/test-one.html [R=301,L]
Position of the envelope-- before or after the other rules-- has no effect. Apache docs say so by implication: Files(Match) rules execute after everything else. I tested it anyway. The "RewriteEngine on" directive has to be present in both places. Docs don't say so; I learned it by experiment.
Although the envelope executes after the non-envelope rules, the result of the earlier rule is discarded. Note in particular that these rules are external redirects, not internal rewrites. So the request has not yet been allowed to leave the building. Rules inside the envelope are applied as if the non-envelope rules had never existed. This happens even if the outer rule-- the one that executed first, according to Apache-- ends in a flat-out [F].
Since this is a test site, I have set html and php files to instant expiration. This saves having to clear the browser cache and reload continuously.
Clearly there is more to FilesMatch than meets the eye. I've read the page on Configuration Sections [httpd.apache.org] backward, upside-down and sideways and simply can't find any discussion of the pattern
as it applies to mod_rewrite