A change in how a site is structured means urls need changing from
site/11-foo/21-bar
to
site/1-foo/1-bar
i.e. I want to use a RewriteRule to subtract a constant (in this example, 10) from the integer in the 2nd argument and another constant (in this example, 20) from the integer in the 3rd argument.
These simple calculations would save literally millions of 301 redirects that would need handling. Is there any way to do it using mod_rewrite?
No, but you can use a RewriteMap and have your variables processed by an external program:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap
There is no calculation within it, http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
While it does have grouping (count of ocurrences) and mapping i would recommend you to use a global rediction to a main index.php and from there create the page it should be displaying by the request data (get,post,cookie,etc) which is what the big forums and most CMS do (examples are, vbulletin, wordpress, ipb) ...