Re: RewriteCond - is this fast fail?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2023-01-11 at 13:12 +0000, sebb wrote:
> Thanks, that's very helpful.
> 
> Maybe this info could be added to the user docs?

There's a useful flow diagram that shows this:

https://httpd.apache.org/docs/current/rewrite/intro.html

Granted, I'm sure it could be made clearer and/or more explicit.


> > > RewriteRule is evaluated first. If that matches, the RewriteCond
> > > directives are evaluated one at a time. If a condition fails, and
> > > there
> > > is no [OR] flag, then the evaluation stops and does not continue
> > > to the
> > > next RewriteCond
> > > 
> > > This is defined in
> > > https://github.com/apache/httpd/blob/trunk/modules/mappers/mod_rewrite.c#L4230
> > >  and onwards.
> > 
> > FWIW, this is also why %N is only available in the substitution
> > argument, and not in the pattern argument of a RewriteRule, as %N
> > hasn't
> > been defined at the pattern matching point of a RewriteRule.
> > 
> > > 
> > > > 
> > > > > On Tue, Jan 10, 2023 at 6:28 PM sebb <sebbaz@xxxxxxxxx>
> > > > > wrote:
> > > > > > 
> > > > > > On Tue, 10 Jan 2023 at 23:21, Frank Gingras
> > > > > > <thumbs@xxxxxxxxxx> wrote:
> > > > > > > 
> > > > > > > The implicit behaviour for multiple RewriteCond
> > > > > > > directives is AND,
> > > > > > > unless you use [OR].
> > > > > > 
> > > > > > Yes, that is documented.
> > > > > > 
> > > > > > > So without [OR], all the conditions have to match to
> > > > > > > apply the
> > > > > > > rewrite rule.
> > > > > > 
> > > > > > Yes, but are any subsequent conditions evaluated?
> > > > > > 
> > > > > > > On Tue, Jan 10, 2023 at 6:06 PM sebb <sebbaz@xxxxxxxxx>
> > > > > > > wrote:
> > > > > > > > 
> > > > > > > > Does the first RewriteCond that fails cause any
> > > > > > > > following RewriteCond
> > > > > > > > entries to be skipped?
> > > > > > > > (up to the RewriteRule)
> > > > > > > > 
> > > > > > > > I would hope that is the case, but AFAICT it is not
> > > > > > > > explicitly
> > > > > > > > stated.
> > > > > > > > 
> > > > > > > > If it is the case, perhaps it would be worth making
> > > > > > > > explicit?
> > > > > > > > (and suggesting that the cheapest checks are done
> > > > > > > > first).
> > > > > > > > 
> > > > > > > > Sebb
> > > > > > > > 
> > > > > > > > -------------------------------------------------------
> > > > > > > > --------------
> > > > > > > > To unsubscribe, e-mail:
> > > > > > > > users-unsubscribe@xxxxxxxxxxxxxxxx
> > > > > > > > For additional commands, e-mail:
> > > > > > > > users-help@xxxxxxxxxxxxxxxx
> > > > > > > > 
> > > > > > 
> > > > > > -----------------------------------------------------------
> > > > > > ----------
> > > > > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > > > > > For additional commands, e-mail:
> > > > > > users-help@xxxxxxxxxxxxxxxx
> > > > > > 
> > > > 
> > > > ---------------------------------------------------------------
> > > > ------
> > > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> > > > 
> > > 
> > > 
> > > -----------------------------------------------------------------
> > > ----
> > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> > > 
> > 
> > 
> > -------------------------------------------------------------------
> > --
> > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> 
> 

> On Wed, 11 Jan 2023 at 12:18, Daniel Gruno <humbedooh@xxxxxxxxxx>
> wrote:
> > 
> > On 2023-01-11 13:16, Daniel Gruno wrote:
> > > On 2023-01-11 12:58, sebb wrote:
> > > > On Tue, 10 Jan 2023 at 23:33, Frank Gingras <thumbs@xxxxxxxxxx>
> > > > wrote:
> > > > > 
> > > > > Do a quick test, and enable the rewrite log. Make sure you
> > > > > use a log
> > > > > level of 5 to see those details.
> > > > 
> > > > Whilst the test might be quick, setting it up is not.
> > > > 
> > > > Does no-one here know the answer?
> > > 
> > > RewriteRule is evaluated first. If that matches, the RewriteCond
> > > directives are evaluated one at a time. If a condition fails, and
> > > there
> > > is no [OR] flag, then the evaluation stops and does not continue
> > > to the
> > > next RewriteCond
> > > 
> > > This is defined in
> > > https://github.com/apache/httpd/blob/trunk/modules/mappers/mod_rewrite.c#L4230
> > >  and onwards.
> > 
> > FWIW, this is also why %N is only available in the substitution
> > argument, and not in the pattern argument of a RewriteRule, as %N
> > hasn't
> > been defined at the pattern matching point of a RewriteRule.
> > 
> > > 
> > > > 
> > > > > On Tue, Jan 10, 2023 at 6:28 PM sebb <sebbaz@xxxxxxxxx>
> > > > > wrote:
> > > > > > 
> > > > > > On Tue, 10 Jan 2023 at 23:21, Frank Gingras
> > > > > > <thumbs@xxxxxxxxxx> wrote:
> > > > > > > 
> > > > > > > The implicit behaviour for multiple RewriteCond
> > > > > > > directives is AND,
> > > > > > > unless you use [OR].
> > > > > > 
> > > > > > Yes, that is documented.
> > > > > > 
> > > > > > > So without [OR], all the conditions have to match to
> > > > > > > apply the
> > > > > > > rewrite rule.
> > > > > > 
> > > > > > Yes, but are any subsequent conditions evaluated?
> > > > > > 
> > > > > > > On Tue, Jan 10, 2023 at 6:06 PM sebb <sebbaz@xxxxxxxxx>
> > > > > > > wrote:
> > > > > > > > 
> > > > > > > > Does the first RewriteCond that fails cause any
> > > > > > > > following RewriteCond
> > > > > > > > entries to be skipped?
> > > > > > > > (up to the RewriteRule)
> > > > > > > > 
> > > > > > > > I would hope that is the case, but AFAICT it is not
> > > > > > > > explicitly
> > > > > > > > stated.
> > > > > > > > 
> > > > > > > > If it is the case, perhaps it would be worth making
> > > > > > > > explicit?
> > > > > > > > (and suggesting that the cheapest checks are done
> > > > > > > > first).
> > > > > > > > 
> > > > > > > > Sebb
> > > > > > > > 
> > > > > > > > -------------------------------------------------------
> > > > > > > > --------------
> > > > > > > > To unsubscribe, e-mail:
> > > > > > > > users-unsubscribe@xxxxxxxxxxxxxxxx
> > > > > > > > For additional commands, e-mail:
> > > > > > > > users-help@xxxxxxxxxxxxxxxx
> > > > > > > > 
> > > > > > 
> > > > > > -----------------------------------------------------------
> > > > > > ----------
> > > > > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > > > > > For additional commands, e-mail:
> > > > > > users-help@xxxxxxxxxxxxxxxx
> > > > > > 
> > > > 
> > > > ---------------------------------------------------------------
> > > > ------
> > > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> > > > 
> > > 
> > > 
> > > -----------------------------------------------------------------
> > > ----
> > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> > > 
> > 
> > 
> > -------------------------------------------------------------------
> > --
> > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux