Answer the question
In order to leave comments, you need to log in
Why does yii/helpers/Url::To generate a crooked URL during testing?
I display the URL generated by the function on the page yii/helpers/Url::To
:
If the entry point is a regular index.php (i.e. I go to the address ), then I see the correct URL:
If the entry point is a test index-test.php (the address is ), then I see the following:
Naturally, when when I click on the link, I get 404. the correct address must be . What is the reason for this behaviour? UPD: Apparently the bug appears only if used in the following way'user/index'])
= Url::to([http://localhost/
/user/index
http://localhost/index-test.php
/index-test.php/index-test.php/user/index
/index-test.php/user/index
Url::To()
\yii\widgets\Menu::widget
\yii\widgets\Menu::widget(
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'],
'items' => [
['label' => Yii::t('app', 'Label'), 'options' => ['class' => 'header']],
[
'label' => 'Users',
'url' => [Url::to(['user/index'])],
],
]
]
[Url::to(['user/index'])]
Url::to(['user/index'])
Answer the question
In order to leave comments, you need to log in
You open the console.
Enter the command
As a result of this command, you should see something like this in the console.
Server started on http://localhost:8080/
Document root is "/home/slonik/localhost/www/test.loc/yii2_test/web"
Quit the server with CTRL-C or COMMAND-C.
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
'<_a:(contact|about)>' => 'site/<_a>',
'<_a:(login|logout|sign-up)>' => 'users/<_a>',
'<_c:[-\w]+>/<_a:[-\w]+>' => '<_c>/<_a>',
'<_c:[-\w]+>' => '<_c>/index',
'<_a:(offline)>' => 'offline/index',
],
],
'urlManager' => [
'showScriptName' => true,
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question