'.htaccess bulk redirect if contains string to new path

old Site urls is like

https://example.com/en/products/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=3934&virtuemart_category_id=275&Itemid=142

and i want to redirect to a new category path

https://example.com/shop/en/14-presentation-scanners

like old category

  • virtuemart_category_id=275 new category is 14-presentation-scanners
  • virtuemart_category_id=276 new category is 15-handheld-scanners

i tried

RewriteRule ^(.*)virtuemart_category_id=275(.*)$ https://example.com/shop/en/14-presentation-scanners [L,R=301]

And

RewriteCond %{REQUEST_URI} virtuemart_category_id=275
RewriteRule ^ https://example.com/shop/en/14-presentation-scanners/? [L,R=301]

but not working, any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source