Paged/Pagination Not Working on URL Rewrite Rule


add_action('init', 'do_rewrite'); function do_rewrite(){     add_rewrite_rule('^shop/men/?$  ', 'index.php?post_type=product&product_tag=men', 'top');     add_rewrite_rule('^shop/men/page/([0-9]{1,})/?$  ', 'index.php?post_type=product&product_tag=men&paged=$  matches[1]', 'top');     flush_rewrite_rules(); } 

The first rewrite rule works great. https://www.example.com/shop/men/ goes directly to https://www.example.com/shop/?post_type=product&product_tag=men with the post_type and product_tag filtered as expected.

Now, if I go to https://www.example.com/shop/?post_type=product&product_tag=men&paged=2

The query and filters in the url, including the new paged of 2, works as intended.

So I assumed my rewrite rule would work the same. But instead it just goes straight to my 404 Page Not Found Error Page.

When I do go to the link with the paged=2 query in the url, it does do a redirect to https://www.example.com/tag/men/page/2/?post_type=product

So my best guess is that there may be some overlap of some sort causing the issue… but I am not sure where to go from here. How can I get my paginated rewrite rule to work with the url https://www.example.com/shop/men/page/2 .../shop/men/page/3 and so forth in my add_rewrite_rule?