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