Get full url of current page in Yii2

How to get the full URl in address bar to my Yii2 Model using yii\helpers\Url ?

I use $currentUrl = Yii::$app->request->url; but it return site/submit which is defined already in my UrlManager :slight_smile:

'urlManager'   => [
    'enableStrictParsing' => true,
    'enablePrettyUrl'     => true,
    'showScriptName'      => false,
    'rules'               => [
        '/'            => 'site/index',
        'site/submit'  => 'site/submit',
        'admin'        => 'admin/index',
        'admin/login'  => 'admin/login',
        'admin/index'  => 'admin/index',
        'admin/logout' => 'admin/logout',
        '/<url:.+>'    => 'site/index',
        'defaultRoute' => 'site/index',

    ],
],

https://www.yiiframework.com/doc/api/2.0/yii-helpers-baseurl#current()-detail

1 Like

Solved with hack $_SERVER[‘HTTP_REFERER’] thanks for your help.

1 Like