Redirect a sub-category to base category Htaccess

Hi,
I want to redirect a sub-category to base Category using htaccess, How can I do that?
Example:

https://www.example.com/category/category-name/sub-category/page/2/ to https://www.example.com/category/category-name/page/2/

Thanks and Regards!

Solution for Apache web server, redirecting from Subcategory to Parent category.

RewriteRule ^category/parent-category-name/subcategory/(.*) /category/parent-category-name/$1 [L,R=302]
1 Like