How to sample redirect page on drupal 8

  1. Add this two line at the top of the controller you want to redirect to another page.

    use Drupal\Core\Url;
    use Symfony\Component\HttpFoundation\RedirectResponse;
  2. Uses the following code make a redirection.

    $redirectPage='/mypage';
    return new RedirectResponse($redirectPage,302);