I've add a custom post type with custom taxonomies. I've also added rewrite rules in order to handle following urls:
courses/languages/english/english-course
where courses is the base slug, languages and english are taxonomy slugs and english-course is my custom post. english-course is a child taxonomy of languages and english-course has been categorized in english-course. My rewrite rule is:
courses/(.+)/(.+)/(.+)/?$ => index.php?thr_course=$matches[3]
Everything works fine but any categories are permitted using this syntax. All following urls are legitimate and work as well:
- courses/languages/french/english-course
- course/products/english/english-course
- course/anycategory/anycategory2/english-course
My rewrite rule is pretty obvious: it only matches my post name ignoring which categories it belongs to. Where and how should I implement a check in order to return 404 if post exists but parent taxonomies are wrong?