Bug 65393 - Bug with Apache processing <If> inside `.htaccess`
Summary: Bug with Apache processing <If> inside `.htaccess`
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: All (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 critical (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-21 15:36 UTC by gilperon
Modified: 2021-06-21 15:36 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gilperon 2021-06-21 15:36:43 UTC
I have a ".htaccess" with only this simple code, which sets a header XXXX based on some conditions:


<If "(%{REQUEST_URI} =~ m#^.*$#)">

    <If "(%{REQUEST_URI} =~ m#^/temp/.*$#)">
    Header set XXXX "BBB2"
    </If>

</If>

<If "(%{REQUEST_URI} =~ m#^/temp/.*$#)">
Header set XXXX "CCC3"
</If>


When I access any file inside "temp" directory the XXXX header is being set to BBB2 instead of CCC3. This "bug" only happens with nested <If>, if I remove the nested above, everything works fine, I mean, the XXXX header is set to CCC3.

After searching a lot on Google, it's pretty clear that each Apache module has its own way of processing rules, in some modules the order in the .htaccess file does not matter and in other modules, the order does matter. However, in the case above I see no explanation for what is going on!

NOTE (1): http -v shows the most recent stable Apache version.

NOTE (2): I know I could use && in the first <If> but my actual code is much more complicated than the one I provided above, so I really needed the nested <If>.