Redirect to a page in a modal I have follow this tutorial to make a modal:
http://www.mediacurrent.com/blog/loading-and-rendering-modal-forms-drupal-8

But when the submitModalFormAjax method is called I want redirect the user to a specific page:

/**
 * AJAX callback handler that displays any errors or a success message.
 */
public function submitModalFormAjax(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();

  // If there are any form errors, re-display the form.
  if ($form_state-&gt;hasAnyErrors()) {
    $response-&gt;addCommand(new ReplaceCommand('#modal_example_form', $form));
  }
  else {
    // &lt;&lt;&lt;--- redirect to homepage
    // $response-&gt;addCommand(new OpenModalDialogCommand("Success!", 'The modal form has been submitted.', ['width' =&gt; 800]));
  }

  return $response;
}


How can I do it?
/**
 * AJAX callback handler that displays any errors or a success message.
 */
public function submitModalFormAjax(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();

  // If there are any form errors, re-display the form.
  if ($form_state-&gt;hasAnyErrors()) {
    $response-&gt;addCommand(new ReplaceCommand('#modal_example_form', $form));
  }
  else {
    $response-&gt;addCommand(new RedirectCommand(Url::fromRoute('&lt;front&gt;')-&gt;toString());
    // $response-&gt;addCommand(new OpenModalDialogCommand("Success!", 'The modal form has been submitted.', ['width' =&gt; 800]));
  }

  return $response;
}