I couldn't parse that "\1$" out... I understand $1 and %1 backreferences, of course, but how does that \1 work?... I tried to read it as an escaped 1 followed by an end anchor, but that did not make sense, since numeric characters don't need to be escaped and the rewrite didn't inject a "1" into the path anywhere above that line anyway...?
Where is this documented? It's very interesting!