You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2019/01/01 11:53:58 UTC

[Bug 63051] New: RewriteRule in section ignored (using multiple sections)

https://bz.apache.org/bugzilla/show_bug.cgi?id=63051

            Bug ID: 63051
           Summary: RewriteRule in <if> section ignored (using multiple
                    <if> sections)
           Product: Apache httpd-2
           Version: 2.4.37
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: All
          Assignee: bugs@httpd.apache.org
          Reporter: Hartmut.Honisch@festo.com
  Target Milestone: ---

When I place RewriteRule statements in different <if> sections that get
executed for a particular request, I would expect that all RewriteRule
statements contained in those <if> sections get executed too. However, it seems
that this is not the case, apparently only the RewriteRule statements in one of
the <if> sections are executed, the others are ignored.

Here's a simple example:

<If "true">
  RewriteRule aaa http://somehost/xxx? [R]  # This rule is ignored
</If>
<If "true">
  RewriteRule bbb http://somehost/yyy? [R]  # This rule is applied
</If>

I would expect all requests containing "aaa" to be redirected to
"http://somehost/xxx" and all requests containing "bbb" to
"http://somehost/yyy".
However, only the "bbb" redirection rule works , the "aaa" rule is ignored.

Placing the RewriteRule statemens outside of any <if> section works fine.
Having only a single <if> section that contains both RewriteRule statements
works fine. 
Using "RedirectMatch" instead of "RewriteRule" works fine, like so:

<If "true">
  RedirectMatch aaa http://somehost/xxx?
</If>
<If "true">
  RedirectMatch bbb http://somehost/yyy?
</If>


How come it works with "RedirectMatch" but not with "RewriteRule"?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 63051] RewriteRule in section ignored (using multiple sections)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63051

Luca Toscano <to...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Luca Toscano <to...@gmail.com> ---
Hi!

This is an interesting use case. As far as I can see, your config behaves the
same even if two Directory blocks with the same paths are used. <If> works in
the directory context, and I believe that mod_rewrite tries to apply only one
block of rules at the time, without merging if not explicitly told (with
Inherit -
https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriteoptions).

Going to follow up with more expert devs to figure out the final answer, it
would be great to add this config as example in the docs.

Hope that helps!

Luca

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 63051] RewriteRule in section ignored (using multiple sections)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63051

hhon <Ha...@festo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |Windows 7

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 63051] RewriteRule in section ignored (using multiple sections)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63051

hhon <Ha...@festo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |Windows 7

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 63051] RewriteRule in section ignored (using multiple sections)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63051

--- Comment #2 from Luca Toscano <to...@gmail.com> ---
More precise answer - the mod_rewrite's default when merging in directory
context (and <If> is part of it) is to override what defined unless explicitly
configured not to do so (with RewriteOptions Inherit for example).

In the example of the two <If>s the "aaa" rewrite gets overridden by the "bbb"
one when the first <If> section is merged into the second one.

RedirectMatch belongs to mod_alias, and as far as I can see the default
behavior is to append, not override.

I'll update the docs to reflect this example :)

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 63051] RewriteRule in section ignored (using multiple sections)

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63051

Luca Toscano <to...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Luca Toscano <to...@gmail.com> ---
I have updated trunk
(http://svn.apache.org/viewvc?view=revision&revision=1853280) and 2.4.x
(http://svn.apache.org/viewvc?view=revision&revision=1853417) with a summary of
what discussed in here. Changing the default behavior of mod_rewrite seems a
bit risky at the moment, so I would go for only a documentation update. I am
going to close this ticket (thanks for opening it!), please re-open if you feel
that something is wrong/missing.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org