Custom urls in WordPress involving page slugs

This exact piece of code works, the reason for redirect was some other plugin.

To create as many child pages you want dynamically you just need to this just hook it to ‘init’ hook.

add_action('init','my_custom_rewrite_rules' );

function my_custom_rewrite_rules(){
    add_rewrite_tag( '%make%', '([^/]+)' );
    add_rewrite_rule('^cars/([^/]+)/?','index.php?make=$matches[1]','top');
   //or To go to a published page.
    add_rewrite_rule('^cars/([^/]+)/?','index.php?pagename=page-slug&make=$matches[1]','top');
}

If you want to use a custom file just do this

add_action( 'template_redirect', 'myown_cars_display' );    

function myown_cars_display($template) {
    if ( $make = get_query_var('make') ){
        include('templates/cars-make.php' );
        exit;
    }
}

Don’t forget to flush the rewrite rules, just open the permalinks page in settings and you are done.