public function redirect($url = null, $statusCode = 302, $options = array())
    {
        $this->setStatusCode($statusCode);
        $this->setOption($options);

        // The variables for custom redirect view
        $escapedUrl = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');
        $wait = (int)$this->redirectWait;

        // Location header does not support delay
        if (0 === $wait) {
            $this->setHeader('Location', $url);
        }

        // Prepare response content
        if ($this->redirectView) {
            ob_start();
            require $this->redirectView;
            $content = ob_get_clean();
        } else {
            $content = sprintf('<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="refresh" content="%d;url=%2$s">
    <title>Redirecting to %s</title>
  </head>
  <body>
    <h1>Redirecting to <a href="%2$s">%2$s</a></h1>
  </body>
</html>', $wait, $escapedUrl);
        }

        return $this->setContent($content);
    }