It can be a bit tricky at first. My sitemap generator plugin uses permalinks to handle pages of the sitemap.
Here is some stripped down code from the plugin:
function yyyyyyy_permalinks($rules) {
global $wp_rewrite;
if ($wp_rewrite->use_verbose_rules || !isset($wp_rewrite->use_verbose_rules)) {
$match_form = '$1';
} else {
$match_form = '$matches[1]';
}
$newrules['xxxxxxx/([0-9]{1,})/?$'] = 'index.php?&pagename=xxxxxxx&pg=' . $match_form;
$newrules = array_merge($newrules,$rules);
return $newrules;
}
function yyyyyyy_query_vars ( $vars ) {
$vars[] = "pg";
return $vars;
}
add_filter('query_vars', 'yyyyyyy_query_vars');
add_filter('rewrite_rules_array', 'yyyyyyy_permalinks');
Notes:
1) replace yyyyyyy with some unique name so the functions do not conflict with anything else
2) replace xxxxxxx with the slug of the page you are checking for the query on.
The first function creates the rules themselves. In this case, it checks for an integer in this format:
https://yoursite.com/xxxxxxx/123
And it translates to this in the back-end
https://yoursite.com/index.php?&pagename=xxxxxxx&pg=123
That is the standard way WP access pages, with the addition of the pg variable, which gets added in the second function.
The second function basically registeres the new pg query var. Otherwise WordPress will ignore it.
It is a starting point for you at least – you will just have to make it fit your needs ??