Redirecting Dynamic URLS to SEO Friendly URLS

Hi All,

We have an old cart using 1.3.5. This site uses dynamic urls. For example:

We are upgrading to 2.2.5 or maybe the new 4.0 version. The new site will be using SEO friendly urls. and will be in the main root instead of a cart folder.

How do I redirect certain old products and categories to new pages on the new site in .htaccess?