Custom rewrite rule takes place AFTER the generic category rule

The answer I’ve come up with on my own I know is a really bad idea. But it works and I have to have a working solution. (Doesn’t mean I can’t fix the problem later…)

add_filter('rewrite_rules_array', 'terminate_with_prejudice');
function terminate_with_prejudice($rules) {
  // if we don't remove this we'll never see our custom rule.
  unset($rules['(.+?)/?$']);

  $rules = array_merge(array(
    'distributors/?$' => 'index.php?show=all&post_type=distributor',
    '((?!distributor)([^/]*?))/?$' => 'index.php?category_name=$matches[1]',
  ), $rules);

  return $rules;
}

What this does is set the default rule to match against something that isn’t “distributor” and has one section prior to the slash.

I just hope no other plugins/themes do this!

Edit:

This breaks the ability to view a page. Great.

I could really use some help on this, folks.