Strip parent categories from url

Viewed 224

I'm struggling to fix an issue with 301 redirects and .htaccess. I have moved a site from an old domain to a new domain. And I have successfully managed to do this with a 301 redirect. Like so:

Redirect 301 / https://newdomain.com

On the old site child category URLs are like this:

olddomain.com/product-category/parent-cat1/parent-cat2/child-cat

or

olddomain.com/product-category/parent-cat1/child-cat

or

olddomain.com/product-category/child-cat

Whereas on the new site they are:

newdomain.com/product-category/child-cat

Unfortunately, this is resulting in 404s from the redirects. Is there any way to remove the parent categories (which can vary by name and amount of them) from the URL?

1 Answers
Related