I am trying to understand what this rewrite condition exactly does:
RewriteCond foo#%{ENV:bar} ^([^#]+)#\1$
As stated in "Using custom environment variables in .htaccess" this could be used as a workaround for testing environment variables in a rewrite condition - e.g. that "foo" equals the value of bar.
EDIT:
Thank you @miah for pointing out what the regex does. Although I still don't get why the variable can be tested in such a way, where it could not be tested directly.
UPDATE:
So when CondPattern does not evaluate the variable and it is evaluated in the TestString, why this does not work in comparison as bar is empty here:
RewriteCond %{ENV:bar} ^foo$