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:



www.domain.com/cart/index.php?target=products&product_id=344

www.domain.com/cart/index.php?target=categories&category_id=4



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.



www.domain.com/search-engine-friendly-product.html

www.domain.com/search-engine-friendly-category.html



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



Thanks





Sean