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

            Bug ID: 69332
           Summary: Strange behavior of nested <If> directives and
                    mod_rewrite
           Product: Apache httpd-2
           Version: 2.4.62
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: All
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

I posted the same question a week ago on the users@mailing-list. No response,
that's why I'm trying it here:

Steps to Reproduce:
I have the following setup in my httpd.conf inside the <Directory
"/usr/local/apache2/htdocs">:
----
RewriteEngine on
RewriteRule ^nonexists.php$ /target.php?nonexists
RewriteRule ^exists.php$ /target.php?exists

<If "%{HTTP_COOKIE} != 'pear'" >
Header always set x-request-first-if "YES"
<If "%{HTTP_USER_AGENT} != 'apple'" >
Header always set x-request-second-if "YES"
</If>
<Else>
Header always set x-request-second-if "NO"
</Else>
</If>
----

The document root has the following files:
exists.php
target.php

Actual Results:
Requesting these URL gives the following result:
GET nonexists.php:
x-request-first-if: YES

GET exists.php:
x-request-first-if: YES

GET target.php:
x-request-first-if: YES
x-request-second-if: YES

Expected result: 
Nested if also gets evaluated even for rewritten requests.

Additional Information:
It even gets a little "spookier". Added a "dummy if" on the
REDIRECT_STATUS and now its working:
----
RewriteEngine on
RewriteRule ^nonexists.php$ /target.php?nonexists
RewriteRule ^exists.php$ /target.php?exists

<If "%{ENV:REDIRECT_STATUS} == 200">
</If>
<If "%{HTTP_COOKIE} != 'pear'" >
Header always set x-request-first-if "YES"
<If "%{HTTP_USER_AGENT} != 'apple'" >
Header always set x-request-second-if "YES"
</If>
<Else>
Header always set x-request-second-if "NO"
</Else>
</If>
----

GET nonexists.php:
x-request-first-if: YES
x-request-second-if: YES

GET exists.php:
x-request-first-if: YES
x-request-second-if: YES

GET target.php
x-request-first-if: YES
x-request-second-if: YES


Could someone explain to me what this behavior is exactly?

I get the same behavior for FreeBSD apache 2.4.62 and the httpd:2.4.62
docker image. I could easily provide my containerized test-setup if
needed.

Thanks for your help.
- Pascal

-- 
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]

Reply via email to