/** * Conditional redirect to canonicalized URI. * @return void * @throws AbortException */ public function canonicalize() { if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) { $uri = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->params, 'redirectX'); if ($uri !== NULL && !$this->getHttpRequest()->getUri()->isEqual($uri)) { $this->terminate(new RedirectingResponse($uri, Nette\Web\IHttpResponse::S301_MOVED_PERMANENTLY)); } } }
/** * Conditional redirect to canonicalized URI. * * @author David Grudl, Jan Tvrdík * @return void * @throws AbortException */ public function canonicalize() { if ($this->request->isMethod('get') || $this->request->isMethod('head')) { $currentUri = $this->getHttpRequest()->getUri(); $optimalUri = $this->getApplication()->getRouter()->constructUrl(clone $this->request, $currentUri); if ($optimalUri !== NULL && !$currentUri->isEqual($optimalUri)) { $this->sendResponse(new RedirectingResponse($optimalUri, IHttpResponse::S301_MOVED_PERMANENTLY)); } } }