First add the query param :

In your functions.php file add the line

function heavy_article_query_vars($query_vars) {
    $query_vars[] = "kbid"; // the name of the custom query param we want to add
    return $query_vars;
}

Next, add the filter function to query vars

add_filter('query_vars', 'heavy_article_query_vars');

Next, create a rewrite using add_rewrite_rule:

/**
* Check for my-url/{INT} and load the page fuze-article with the KBID as a query param instead
*
* @param [type] $aRules
* @return void
*/
add_action(
    'init',
    function() {
        add_rewrite_rule( 'my-url/([0-9]+)/?$', 'index.php?pagename=my-page-slug&content_id=$matches[1]', 'top' );
    }
);

The add_rewrite_rule takes 3 parameters.
1. the url to rewrite – in this case we are using the regex ([0-9]+)/?$ to check for an integer value as the last fragment.
2. the page we want to route the request, wehre page name is the template slug of a page we’ve created, and then we are adding a query string that uses the $matches variable to take the url fragment in position 1 and set that as the content_id param we create in the first step

Finally, in our template file, we just need to check the query to see if the param exists, and if so sanitze it and set it to a variable we can use in our page.

in custom-template.php:

if (isset($wp_query->query_vars['kbid'])) {
    $content_id = filter_var(urldecode($wp_query->query_vars['content_id']), FILTER_SANITIZE_NUMBER_INT);
    echo $content_id
}