https://issues.apache.org/bugzilla/show_bug.cgi?id=51964
Bug #: 51964
Summary: Documentation of RewriteRule flag skip unclear
Product: Apache httpd-2
Version: 2.3-HEAD
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Documentation
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
The documentation of the skip flag of RewriteRule is unclear:
http://httpd.apache.org/docs/current/en/rewrite/flags.html#flag_s
The section reads:
The [S] flag is used to skip rules that you don't want to run. This can be
thought of as a goto statement in your rewrite ruleset. In the following
example, we only want to run the RewriteRule if the requested URI doesn't
correspond with an actual file.
# Is the request for a non-existent file?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# If so, skip these two RewriteRules
RewriteRule .? - [S=2]
RewriteRule (.*\.gif) images.php?$1
RewriteRule (.*\.html) docs.php?$1
This technique is useful because a RewriteCond only applies to the RewriteRule
immediately following it. Thus, if you want to make a RewriteCond apply to
several RewriteRules, one possible technique is to negate those conditions and
use a [Skip] flag. So, you can use this to make pseudo if-then-else constructs:
The last rule of the then-clause becomes skip=N, where N is the number of rules
in the else-clause.
Thanks to the example, I'm able to understand how it works. I understand the
analogy to goto, although goto-s do not take relative line numbers AFAIK, so
this could be clarified. The bit saying that "one possible technique is to
negate those conditions and use a [Skip] flag" could be clarified with "one
possible technique is to negate those conditions and to add a rule which uses a
[Skip] flag".
What I find really unclear is the analogy with if-then-else. I understand there
are conditions, so I see an equivalent of the if part. If the conditions do not
match, an else block is executed, so I see an equivalent here too. But I don't
see an equivalent to the then part. I don't understand the sentence "The last
rule of the then-clause becomes skip=N, where N is the number of rules in the
else-clause."
"The last rule of the then-clause becomes skip=N" is very unclear to me.
I suggest to add an example analogy to clarify, giving a pseudocode equivalent
to the snippet above, saying "If Apache configuration would support if
structures, we could have written something like: [...]. Instead, we write:
[snippet above]."
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]