wordpress联系form7,一个表单重定向到基于is_page的多个感谢页面

I am looking for a solution on wordpress contact form7. either a plugin or in PHP code. I am not looking for JavaScript solution. as I have already found JavaScript solution. Again: I am looking for either plugin or PHP code. I want to use one form (CF7) and it will redirect to multiple thank you pages based on from which page the form submitted. Below example code.

if is_page(1){
  contact-form will go to thank-you-page-1
} else if is_page(2) {
  contact-form will go to thank-you-page-2
}

You can do by this hook

add_action('wpcf7_mail_sent', function ($cf7) {

    // Run code after the email has been sent
$wpcf = WPCF7_ContactForm::get_current();
 $wpccfid=$wpcf->id;

    // if you wanna check the ID of the Form $wpcf->id
     if ( '34' == $wpccfid ) { // Change 123 to the ID of the form 

         //you can use also if(is_page()){} condition 

    //redirect to url
    wp_redirect('url of thank you page');
     exit();

     }
}