You can easily parse the URL by making fun of the object Requestand passing it to UrlManger.
Imagine that we have a URL http://example.com/user/42, but UrlManagerhas the following rule:['user/<id:\d+>' => 'user/view']
$request = new Request(['url' => parse_url(Yii::$app->request->referrer, PHP_URL_PATH)]);
$url = Yii::$app->urlManager->parseRequest($request);
var_dump($url);
Cool, right? :)
source
share