I have built a custom Wordpress theme using UnderStrap. My web site uses archive pages to display the content of all categories/subcategories. The structure is like
Parent Category > subcategory
My URL structure for archive pages is www.example.com/category/parent-category/subcategory. This is working fine but now the problem is that it is still loading the subcategory content if I use following URLs
www.example.com/category/subcategory www.example.com/category/any-string/subcategory
Is there a way I can stop it and start displaying 404 errors?
I have tried a "redirect_canonical" filter but it's not helping at all.