Araz Jafaripur
Araz Jafaripur

Reputation: 906

generate url in module and outside of module in Yii2

I have a module with the name of admin. when i generate link with Url::to(['admin/assignment']) outside of module it's work and create this link:

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

but when this url generated in running current module it's create this linke and doesn't work

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

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

Upvotes: 6

Views: 3355

Answers (1)

david
david

Reputation: 421

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

Upvotes: 13

Related Questions