(answer totally rewritten)
OK, first of all, I had to change your idea into using @back
and @front
aliases, because @backend
and @frontend
aliases are already defined in common/config/bootstrap.php file. And since they sit in bootstrap, they get higher precedence over things defined in main.php.
So, without this modification I was getting (out of your Url::to(['@backend/site/index', 'param' => 'value'])
a link like:
http://localhost/company/project/backend/web/C:/XAMPP/htdocs/company/project/backend/site/index?param=value
So, I made this change and replaced first sub-array of common/config/main.php from:
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
Into:
'aliases' => [
'@npm' => '@vendor/npm-asset',
'@bower' => '@vendor/bower-asset',
'@back' => 'backend',
'@front' => 'frontend',
],
Then calling your code produced a link like:
http://localhost/company/project/backend/web/backend/site/index?param=value
I think that the biggest challenge here is to get full URL to the other application, while sitting in the first one. As Kartik has written, this may be impossible due to complete separation of these two applications in the ecosystem of Yii 2 App Advanced Theme-based apps.
My suggestion works, because this is a dirty string replacement. I am starting to think that a cleaner or more professional way may not exist.