How does Apache tell the difference between a direct request and a rewritten request?
Would you be content with an assurance that yes, it can tell?
In human terms again: THE_REQUEST is what you see in your logs. If the request leads to a redirect (301 or 302) you will see two consecutive requests in your logs. But if it leads to a rewrite, the logs are silent. Your only hint is if you study the logs closely; then you might notice that the filesize (the number after the 200) is different from the size of the "real" file. The "real" file may not even exist.
Also: search-engine robots can "see" a Redirect and can choose not to follow it. But they are powerless against a Rewrite.
What I didn't realize was that as soon as you declare a rule it resets the RewriteCond's.
That's an important thing to remember, and it's one reason people tell you to leave a blank space after each Rule. Any given Condition or group of Conditions applies
only to the immediately following Rule.
I've got a nasty feeling that either you've got your code backward or everyone has been reading your original question backward. I thought what you wanted to do was:
If the user requests
sub.example.com/blahblah
serve content from
www.example.com/sub/blahblah {rewrite with L flag only}
So far so good. Only then, to avoid duplicate content, you have to deal with the users who type in the "sub/" version on purpose:
www.example.com/sub/blahblah
has to get redirected [R=301,L] to
sub.example.com/blahblah
so that everyone's address bar shows the same thing. This is the rule that requires a THE_REQUEST condition to keep from going into an infinite loop. You are only redirecting people who actually
asked for this form. You are not doing anything to Apache's internal request for this identical form.
Finally: index.html should never appear in a Redirect target. The official name of a directory ends in / slash. For a Rewrite target you
do have to include the index.html (or .php or whatever you've got), because that's where the content lives. And speaking of slashes: you don't need to escape \. full stops-- or anything else-- in the target (the part on the right in the Rule). Only in the Pattern.