Redirect to a page in a modal
/**
 * 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;
}