Apache mod_rewrite [E] flag
From the mod_rewrite docs:
‘env|E=VAR:VAL’ (set environment variable)
This forces an environment variable named VAR to be set to the value VAL, where VAL can contain regexp backreferences ($N and %N) which will be expanded. You can use this flag more than once, to set more than one variable. The variables can later be dereferenced in many situations, most commonly from within XSSI (via ) or CGI ($ENV{’VAR’}). You can also dereference the variable in a later RewriteCond pattern, using %{ENV:VAR}. Use this to strip information from URLs, while maintaining a record of that information.
I don’t know how I overlooked this for so long, but this is really useful. Instead of requiring overly-complex regex, tons of extra back-references and daisy-chained RewriteRules, with [E] you can just set these vars explicitly and use them when you need them. Nice!
