my rules config is:
[
'pattern' => 'admin/post',
'route' => 'admin/default/post',
],
it's work! when open http://example.com/admin/post
show admin/default/post
for me,
but when i want create dynamic url with this code:
echo \yii\helpers\Url::to('/admin/default/test');
output is http://example.com/admin/default/test
who to create a dynamic url correctly?
About Url::to()
This method is very similar to
[[toRoute()]]
. The only difference is that this method requires a route to be specified as an array only. If a string is given, it will be treated as a URL.
You need to pass an array
rather than string
\yii\helpers\Url::to(['/admin/default/test']);