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!
For example, you can use the following code to create a URL for the post/view action: use yii\helpers\Url; // Url::to() calls UrlManager::createUrl() to create a URL $url = Url::to(['post/view', 'id' => 100]);
To get the base URL of the current request use the following: $relativeBaseUrl = Url::base(); $absoluteBaseUrl = Url::base(true); $httpsAbsoluteBaseUrl = Url::base('https'); The only parameter of the method works exactly the same as for Url::home() .
Yii::app()->request->getUrl(); Yii::app()->request->getParams('id'); $_GET['id'];
Try Url::to(['/admin/assignment'])
(with the leading /): routes without the leading / are interpreted as relative to the current module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With