Overwrite WordPress’s URL rewrite not working

WordPress has its own rewriting system in PHP so you can do it both ways

If you want to rewrite these url from htaccess, i would only make it rewrite

http://www.example.com/newsletter/confirm/token to http://www.example.com/newsletter/?ut=token

instead of trying to rewrite http://www.example.com/newsletter/confirm/token to http://www.example.com/index.php?page_id=4058&ut=token

And let WordPress handle the page id rewrite.

So the htaccess rule would be:

RewriteRule ^newsletter/confirm/(.+)/?$ /newsletter/?ut=$1 [L,NC]

Alternatively you can define your rewrite rule in the WordPress rewrite system:

add_rewrite_rule('^newsletter/confirm/(.+)/?$', 'index.php?page_id=4058&ut=$matches[1]', 'top');

Anyway, to access this new query variable you have to declare it in WordPress aswell:

add_filter('query_vars','my_add_ut_query_var');

function my_add_ut_query_var($vars) {
    array_push($vars, 'designer');
    return $vars;
}

Now you can access it from your page template:

$token = get_query_var('ut')

And don”t forget to flush your rules when you add a new one of course 🙂

(Also be careful you have a typo with your uc or ut parameter)