Am I correct in my understanding that this will open /folder1/file.php any time the user visits a URL that does not contain 'folder1'?
That's correct.
Some notes from the mod_rewrite documentation:
The variables SCRIPT_FILENAME and REQUEST_FILENAME contain the same value - the value of the filename field of the internal request_rec structure of the Apache server. The first name is the commonly known CGI variable name while the second is the appropriate counterpart of REQUEST_URI (which contains the value of the uri field of request_rec).
If a substitution occurred and the rewriting continues, the value of both variables will be updated accordingly.
That means the condition checks if the string folder
exists anywhere in this variable.
The rule doesn't have a match in it specifically, but the target is the fully qualified absolute path of the file on the filesystem. The rule's target can be either a file-path or a URL-path, and in this case, it's a file-path. Mod_rewrite isn't always the brightest when it comes to figuring out which is which, so it's possible for it to be confused with this being a URL path, but probably not.
Once the request has been rewritten to /folder1/file.php
, then the rewrite engine loops, the rule gets applied again, but this time, the %{SCRIPT_FILENAME}
variable contains "folder1" and the rule isn't applied.