Custom rewrite rule, url returning 404

I think I figured it out… almost. I needed to use WordPress’ own rewrite engine to define the rewrite rules so it recognizes what I’m doing.

So I added this to my WordPress theme’s functions.php:

add_action( 'init', 'init_custom_rewrite' );

function init_custom_rewrite() {
    add_rewrite_rule(        
        '^show/([^/]*)/([^/]*)/?',        
        'index.php?page_id=2382&id=$matches[1]&n=$matches[2]',        
        'top' );
}

add_filter('query_vars', 'my_query_vars', 10, 1);

function my_query_vars($vars) {
    $vars[] = 'id';
    $vars[] = 'n';
    return $vars;
}

The URL website.com/show/9999/page-name works correctly.

Now I need to redirect the old query string URL: website.com/show/?id=9999&n=page-name to the new SEO friendly url: website.com/show/9999/page-name

I do that with some rewrite rules in .htaccess:

RewriteCond %{QUERY_STRING} ^id=([^/]*)&n=([^/]*)$ 
RewriteRule ^showtest/?$ /showtest\/%1\/%2\/? [R=301,L]