Actually, RewriteRule’s match pattern is not affected by query strings. You can use the QSA option to append the query string to the substitution.