修改请求路径信息

Now, let me guess what y'all may be thinking... "It's a bad idea to modify the path info before it's processed. Why would you ever want to do that? This is malicious behavior!!!"

I am trying to get a controller/action representation of my previous URL; gotten through Yii::app()->getRequest()->getUrlReferrer().

From Yii 2 issues, it's possible to set the path info for a new request and parse that request. However, from the Yii 1 source, the only methods which deals with the path info are getPathInfo() and decodePathInfo(). If there was a setPathInfo(), I could have used that and the urlManager->parseUrl() to achieve this. But we aren't allowed to set the path info.

How can I arrive at a controller/action representation of my previous URL?

Yii does not allow the CHttpRequest object live past the parsing of the routes. And creating a new CHttpRequest is impossible after the app is created.

I realized the only way to go about this is the vanilla Yii::app()->controller->action object. From this, I could get the module, controller and action ID for the specific URL.

Using PHP $_SERVER['HTTP_REFERER'] it's good way to find previous location but will give you incomplete url.

You can try this way in Yii 1.0 -

if your url like - www.domain.com?r=site/page

if(isset($_REQUEST['r']) && !empty($_REQUEST['r'])){
    $previous_location = $_REQUEST['r'];
    Yii::app()->user->setState('previous_location', $previous_location);
}

Another way-

$controller_name = Yii::app()->controller->id;
$action_name = Yii::app()->controller->action->id;

Yii::app()->user->setState('previous_location', $controller_name.'/'.$action_name);

so you can find out your previous location by -

echo Yii::app()->user->getState('previous_location');

It's may be help you to resolve your issue.