Get current URL/URI without some of $_GET variables
Asked 07 September, 2021
Viewed 1.5K times
  • 62
Votes

How, in Yii, to get the current page's URL. For example:

http://www.yoursite.com/your_yii_application/?lg=pl&id=15

but excluding the $GET_['lg'] (without parsing the string manually)?

I mean, I'm looking for something similar to the Yii::app()->requestUrl / Chtml::link() methods, for returning URLs minus some of the $_GET variables.

Edit: Current solution:

unset $_GET['lg'];

echo Yii::app()->createUrl(
  Yii::app()->controller->getId().'/'.Yii::app()->controller->getAction()->getId() , 
  $_GET 
);

16 Answer