I want to add product category in the URL of the product and add 301 redirect from old URL (without category) to new URL (with category) for a Magento site. There are nearly 6000 products with 30 different categories, which makes it impossible to add all redirects in .htaccess.
Here is and example for what I'm trying to do-
OLD URL looks like - http://domainname.com/product-name.html
NEW URL will look like - http://domainname.com/category/product-name.html
It's easy to configure the URL, but I want to add 301 redirect for SEO purpose.
So that, if anyone hits old URL - http://domainname.com/product-name.html in search results, then he should get redirected to http://domainname.com/category/product-name.html
Thanks.
You can write custom script and you can add custom rewrite magento