/** * Redirects the web request to another uri. * * NOTE: This method only supports web requests and will thrown an exception if used with other request types. * * @param mixed $uri A string representation of a URI * @param int $delay (optional) The delay in seconds. Default is no delay. * @param int $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other * @throws UnsupportedRequestTypeException If the request is not a web request * @throws StopActionException * @api */ protected function redirectToUri($uri, $delay = 0, $statusCode = 303) { if (!$this->request instanceof WebRequest) { throw new UnsupportedRequestTypeException('redirect() only supports web requests.', 1220539735); } $this->objectManager->get(\TYPO3\CMS\Extbase\Service\CacheService::class)->clearCachesOfRegisteredPageIds(); $uri = $this->addBaseUriIfNecessary($uri); $escapedUri = htmlentities($uri, ENT_QUOTES, 'utf-8'); $this->response->setContent('<html><head><meta http-equiv="refresh" content="' . (int) $delay . ';url=' . $escapedUri . '"/></head></html>'); if ($this->response instanceof \TYPO3\CMS\Extbase\Mvc\Web\Response) { $this->response->setStatus($statusCode); $this->response->setHeader('Location', (string) $uri); } throw new StopActionException('redirectToUri', 1476045828); }