Generate url in module and outside module in Yii2

I have a module called admin. when I create a link with Url :: to (['admin / assign']) outside the module, it works and creates this link:

http://localhost:8080/test/backend/web/admin/assignment.html

but when this url generated in the current current module creates this link and does not work.

http://localhost:8080/test/backend/web/admin/admin/assignment.html

how can I create a rule in the route (UrlManager) for a control problem like this!

+4
source share
1 answer

Try Url::to(['/admin/assignment'])(with the leading /): routes without the leading / are interpreted as relative to the current module.

+8
source

All Articles