If you use the Url helper to generate URLs, you will need to set the baseUrl key for the UrlManager component
'urlManager' => [ 'baseUrl' => 'http://example.com',
Then you can create an absolute URL using the Url as helper,
echo Url::to(['site/index', 'src' => 'ref1', '#' => 'name'], true); // output ===> http://example.com/index.php?r=site%2Findex&src=ref1#name
Sachin G.
source share