Get Route Name from Path I am building a module on drupal 8 to make a redirection after a form is submitted

function form_redirect_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
    $form['actions']['submit']['#submit'][] = 'ptt_contact_form_blocks_submit';
}


function ptt_contact_form_blocks_submit($form, FormStateInterface $form_state) {
    $form_state-&gt;setRedirect($route_name);
}


but for the setRedirect, it needs to have the route name. Like if i want to redirect to node/24, then how can i find the route name of the node?

Thanks!
check this one

function ptt_contact_form_blocks_submit($form, FormStateInterface $form_state) {
    $form_state-&gt;setRedirect('node/24'); // node/$node-&gt;nid
}