Apache mod_rewrite RewriteRule with query string

I was converting some mod_rewrite rules from the Lighttpd webserver to Apache today.

While Lighttpd and Apache both have request rewriting modules with pretty equivalent functionality, there are some significant differences nonetheless. Specifically, I was trying to rewrite a URL of the form:

/script?key=123abcxyz

to a file on the local disk:

/abc/123/123abcxyz

In Lighttpd, I had a single rewrite [...]