3

I got one awkward issue.

My views/layout/main.php is:

echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'items' => [
                Yii::$app->user->isGuest ?
                ['label' => 'Register', 'url' =>['users/users/register']]:
                ['label' => 'D',''=>''],

                ['label' => 'Home', 'url' => ['users/users/index']],
                ['label' => 'About', 'url' => ['users/users/about']],
        ],
    ]);
    NavBar::end();
    ?>

Whenever I'm clicking On Home Tab, Page is opening. Its Ok.

http://localhost/mylawsuit/yii/web/index.php?r=users/users/index

enter image description here

Again Clicking on Home Tab, Page giving error Like

Page Not Found.

http://localhost/mylawsuit/yii/web/index.php?r=users/users/users/index

enter image description here

In Url, one more "users" getting appendend in middle. That's why Page Not Found Coming. Users is one module.

Again, clicking On Home Tab, Page is coming without error. Means Original Page Coming.

For me, i've to click 2 times each on every tab to get original page. First time, error. Second Time, Original Page.

But, I solved it by changing 'url' => ['users/users/index']] of main.php to 'url' => ['/users/users/index']], means adding one forward slash to URL. It's working fine.

What may be the issue. Or Writing like this 'url' => ['/users/users/index']] is the main syntax. Forgive me, If this is the syntax to write the URL.

Nana Partykar
  • 10,556
  • 10
  • 48
  • 77

1 Answers1

0

You just need to use absolute url with / on begining like:

'url' => ['/users/users/index']

without / Yii creates a relative url which is relative to current page, absolute url is always the same on every page.

Lesser Jank
  • 381
  • 1
  • 4
  • 9