Custom Params in URL

The regex you have in the rewrite rule, ([0-9]+), will not match your query string ex%2021. Try ?b=21 and see if that works.

Also, new rewrite rules require that the rewrite rules are flushed. You can do this one of two ways. Either call flush_rewrite_rules(); or go to Settings > Permalinks and click save.

Please note, you DO NOT want flush_rewrite_rules(); to be called on a live site, so remove it when you’re done developing.