/** * Check if a redirect exists and forward according to the redirects url and status */ public function forwardIfExists() { $url = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); $request = parse_url($url); $path = trim($request['path'], '/'); $host = $request['host']; $scheme = $request['scheme']; if ($path !== '') { $redirect = $this->redirectRepository->findByPathAndDomain($host, $path); if ($redirect) { $this->redirect($redirect, $scheme, $host, $path); } } }
/** * Check if a redirect exists and forward according to the redirects url and status * * @return void */ public function forwardIfExists() { /** @var \PatrickBroens\UrlForwarding\Domain\Model\Redirect $redirect */ $redirect = false; $request = parse_url(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); $path = trim($request['path'], '/'); $host = $request['host']; if ($path != '') { $redirect = $this->redirectRepository->findByPathAndDomain($host, $path); } if ($redirect) { header($redirect->getHttpStatus()); header('Location: ' . $redirect->getUrl()); exit; } }