How to redirect comment form? I want to redirect to a node after comment form submit.
But I tried  using hook_form_alter hook,the redirect not happen.
function pf_core_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
 if($form_id=='comment_comment_form'){
   $form['#submit'][] = 'pf_core_comment_comment_form_submit';
 }
}

function pf_core_comment_comment_form_submit(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form_state-&gt;setRedirectUrl('&lt;front&gt;');
}

Please help me to fix this issue.
$nid = 1; // lets pretend the node ID you want to redirect is 1.

$url = \Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' =&gt; $nid]);
$form_state-&gt;setRedirectUrl($url);