You should not do this "silently," or you will end up with a bunch of old URLs floating around in search results and the files for those old URLs will also be accessible using new URLs. This is duplicate-content, and will negatively affect your search engine rankings for those files/threads/posts.
I suggest that you externally redirect all old URLs to their corresponding new URLs to avoid this.
Please post your code as a starting point for further discussion.
In .htaccess use RewriteRule to externally 301 redirect all direct client requests for the old URLs. This will cause the browser, and searchengines, to make a new request for the new URL.
'Silently' implies an internal rewrite, which means that the old and new URL both continue to return '200 OK' meaning that both URLs continue to be indexed. You need to avoid that - only the new URLs should be indexed.
We cannot write your code for you here -- This forum is global in reach, and we don't have enough volunteer contributors to keep up with that kind of "support." We are a discussion forum, not a free "help desk."
After reviewing the resources cited in our Apache Forum Charter, looking through our Apache Forum Library, and using the WebmasterWorld site search facilities to find related previous threads, please post your best attempt at coding a solution as a basis for on-going discussion. Links to these resources are at the top of this page.
Do you have any working mod_rewrite rules? If not, then either both of these lines or only the second line will be required ahead of the code above; You will have to test one or both, because it depends on your server configuration:
Options +FollowSymLinks -Indexes -MultiViews RewriteEngine on
Delete your browser cache after making any change to your server-side code.