I have a site which has pages that show products (these aren't sold on the site, though, it's just informational).

Some categories have subcategories, so the URI for a subcategory archive page looks like this:

```/products/category-1/category-1-child/```

But some categories don't have any subcategories, so the URI for a product post in that category looks like this:

```/products/category-2/product-name/```

So either the first URL works and the 2nd one is 404, or the second URL works and the first one is 404, as either a subcategory name or a post slug can be in that third position in the URL.

I suspect that the WP's built-in process which resolves permalinks to an internal URL which has the relevant information in query vars, seems to be unable to tell whether the URL points to a subcategory or a product post in a single-level category. 

I've tried all sorts of settings using ```rewrite_rules_array``` but I can only ever get one or the other working.

Here's what I have in the ```rewrite_rules_array``` that works for posts but not subcategories, for example:

```php
$new_rules['products/([^/]+)/([^/]+)/?$'] = 'index.php?product_category=$matches[1]&product=$matches[2]';
```

And here's a rule which works for a subcategory archive page, but fails on a single-level-category post: 

```php
$new_rules['products/([^/]+)/([^/]+)/?$'] = 'index.php?product_category=$matches[2]';
```
(Though this is also the default behaviour if I don't add anything.)

Note that the array key is the same for both URLs, as they both have the same URL format. I'm sure I'm missing something simple here!