In the end, I realized the problem that made it not work as I expected.
How lighttpd rewrites mod, it evaluates all url.rewrite commands before it evaluates its $ HTTP ["url"] conditional expressions, which means that any url.rewrite commands placed in $ HTTP ["url"] conditional will have no effect.
I was not able to find a good solution for the implementation that I was looking for with this restriction, and instead ended up moving the rewriting part downstream to another server (node ββin this case), which I proxied traffic to.
This is freely stated in the lighttpd ModRewrite file with this line:
NOTE: url rewriting does not work within a $HTTP["url"] conditional.
source share