Yii Redirect Tutorials

Yii CHttpRequest

CHttpRequest is equal to ‘$_SERVER’. we are using ‘$_SERVER’ variable to get the details of request, scripts, headers etc. We can get this information using CHttpRequest class. We can access the CHttpRequest via Yii::app()->request. It will return browser accept types, baseurl, csrftoken, csrftoken name, host name, request type [POST, AJAX, GET, PUT, DELETE], request Uri, url, url Referrer, user Agent, user Host Address and moreYii::app()->request->acceptTypesYii::app()->request->baseUrlYii::app()->request->csrfTokenYii::app()->request->csrfTokenNameYii::app()->request->hostInfoYii::app()->request->isAjaxRequestYii::app()->request->isDeleteRequestYii::app()->request->isFlashRequestYii::app()->request->isPostRequestYii::app()->request->isPutRequestYii::app()->request->requestUriYii::app()->request->urlYii::app()->request->urlReferrerYii::app()->request->userAgentYii::app()->request->userHostAddressRedirect ScriptNote: sitepath is “http://127.0.0.1/httprequest”Yii::app()->request->acceptTypesaccetTypes is […]... Read More »

Redirect Script in Yii

When we try to load one page, we can redirect that request to another page. Yii framework support redirection method. Yii redirect function is used to redirect the one controller action to another controller action and also we can redirect within controller. The types of redirections areRedirect AnywhereRedirect Within ControllerRedirect Between ControllerRedirect Anywhere// We can redirect anywhere in application Yii::app()->request->redirect(Yii::app()->createAbsoluteUrl("user/view")); // We can redirect anywhere in application with parameter Yii::app()->request->redirect(Yii::app()->createAbsoluteUrl("user/view",array("id"=>$id))); […]... Read More »