Can anyone help me, I am trying to sort out some redirects using htaccess but I am facing a tricky issue.
The part I cannot figure out is this: I have a system which creates 2 urls for some pages of the following pattern:
products/category (what we are using mostly and what we want, regardless of category depth)
products/subcategory/category (better for SEO maybe but not what we want)
How can I write a 301 redirect to strip out the /subcategory part of the url and redirect to the shorter version where we have in the region of 80 subcategories so I don’t want to attempt this one by one. I am trying to get to grips with Regex but I am totally green with it, I am assuming matching the subcategory isn’t too hard as it always follows /product and always ends with / but how do I redirect it to the shortened version.
I can’t think of more information to add but if I haven’t given enough detail let me know, I would love some help with this.
Thanks
Try these lines in your htaccess file :