Understand that the link seen by your visitors must be the friendly ones. That means that the friendly URLs must be used on your pages and possibly, on your affiliates' pages. Mod_rewrite can then be used, once one of these friendly URL requests is received by your server, to re-arrange it into the form needed to run your scripts.
However, I used the term 're-arranged' advisedly, since information cannot be added. And what that means is that in this scenario, you'd have to delete the affiliate IDs from your pages, and ask them to delete them from ther pages, and once deleted, mod_rewrite could certainly not recover them. As such, mod_rewrite offers no solution to this problem.
This thread [webmasterworld.com], while not addressing your specific problem, describes the step-by-step process of URL rewriting and what it means.