Prevent WordPress canonical URL rewrite when using pagination

If you have a page with  slug /slug and in that page you add a custom pagination or query string ?page=MyCustomPage and then reload the browser, Worpdress will rewrite the url to /slug/MyCustomPage

If you want to prevent this from happening you should add the following filter in your theme’s functions.php file

add_filter( 'redirect_canonical', function ( $redirect_url ) {
   if ( is_page_template( 'page-with-custom-paging.php' ) ) {
      $redirect_url = false;
   }

   return $redirect_url;
} );