URLs

controller/action vs /controller/action

Any URL created in module context is relative to the module unless fully qualified – Yii assumes the controller/action belongs to the module (most often not true).
E.g. Url::to([‘user/home’]) called in payroll\views\summary\index.php will generate host/payroll/user/home (invalid). Correct: Url::to([‘/user/home’]) (leading / ).

URLs (action routes) created and rendered in layout views (e.g. layouts/main, app-menu etc) and in module context should be fully qualified (with leading slash) otherwise they fail in module context.

Lots of cool stuff about URLs: http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html

 

About

Das Yii Man

Leave a Reply

Your email address will not be published. Required fields are marked *

[TOP]