コード例 #1
0
ファイル: Presenter.php プロジェクト: jff15/travelbot
 /**
  * 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));
         }
     }
 }
コード例 #2
0
	/**
	 * 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));
			}
		}
	}