Custom permalink not working and showing 404 page not error

I had the same technical need as you, and I have did this(code below) to get it work :

function my_custom_rewrite_tag() {
  add_rewrite_tag('%xxx%', '([^&]+)'); //change the regex to your needs
  add_rewrite_tag('%yyy%', '([^&]+)'); //change the regex to your needs
}
add_action('init', 'my_custom_rewrite_tag', 10, 0);


function my_custom_rewrite_rule() {
    add_rewrite_rule('^tour/([^/]*)/([^/]*)/?','index.php?pagename=tour&xxx=$matches[1]&yyy=$matches[2]','top');
}
add_action('init', 'my_custom_rewrite_rule', 10, 0);

Finally, do not forget to flash the permalinks structure from your dashboard.