code: public function redirect(string $url = '', int $statusCode = 302)
      {
          $this->is404 = false;
          $server = filter_input_array(INPUT_SERVER);
          if ('' == $url && isset($server['REQUEST_URI'])) {
              $url = '/' . trim($server['REQUEST_URI'], '/');
              preg_match('/^[\\a-zA-Z0-9-\._~:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=%]*$/iD', $url, $match);
              $url = $match[1] ?? '';
          }
  
          if (!headers_sent()) {
              header('Location: ' . $url, true, $statusCode);
          }
  
          echo sprintf('<!DOCTYPE html>
  <html>
      <head>
          <meta charset="UTF-8" />
          <meta http-equiv="refresh" content="0;url=%1$s" />
          <title>Redirecting to %1$s</title>
      </head>
      <body>
          <script type="text/javascript"> window.location.href = "%1$s"; </script>
          Redirecting to <a href="%1$s">%1$s</a>.
      </body>
  </html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'));
  
      }
docs: Redirect to url with statusCode and terminate.
  
  @param string $url
  @param int $statusCode