You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@httpd.apache.org by bu...@apache.org on 2011/10/05 18:54:45 UTC
DO NOT REPLY [Bug 51964] New: Documentation of RewriteRule flag skip
unclear
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: docs@httpd.apache.org
ReportedBy: chealer@gmail.com
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: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org
DO NOT REPLY [Bug 51964] Documentation of RewriteRule flag skip
unclear
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51964
Filipus Klutiero <ch...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |VERIFIED
--- Comment #2 from Filipus Klutiero <ch...@gmail.com> 2012-04-10 15:47:55 UTC ---
Ah, I see now. Thank you, that is a lot clearer.
I would still suggest some clarifications.
"This can be thought of as a goto statement in your rewrite ruleset."
could be
"This can be thought of as a forward-only goto statement in your rewrite
ruleset."
Also, the formulation "The last rule of the then-clause becomes skip=N, where N
is the number of rules in the else-clause:" for the if-then-else example would
make me think of the following if clause:
RewriteRule (.*\.gif) images.php?$1
RewriteRule (.*\.html) docs.php?$1 [S=1] # Skip past the "else" stanza.
Instead, we give
RewriteRule (.*\.gif) images.php?$1
RewriteRule (.*\.html) docs.php?$1
# Skip past the "else" stanza.
RewriteRule .? - [S=1]
I would present this form this way:
"A skip=N rule is added at the end of the then-clause, where N is the number of
rules in the else-clause:"
Finally, it would be nice to start by explaining the argument (N).
--
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: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org
DO NOT REPLY [Bug 51964] Documentation of RewriteRule flag skip
unclear
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51964
Daniel Gruno <da...@gruno.dk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #1 from Daniel Gruno <da...@gruno.dk> 2012-03-31 08:14:10 UTC ---
Clarified and if-then-else example given, although with 2.4, this could
probably be handled with a real <If> directive as well.
--
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: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org