A
A
Alexander Pantyukhov2016-05-30 13:59:10
Yii
Alexander Pantyukhov, 2016-05-30 13:59:10

How to properly generate links in yii2?

Good day.
Faced with the problem of generating links. Everything works fine on the server, but not so well locally. On the server, the link should look like "dom.com/admin/index.php" and locally it should look like " 127.0.0.1/dom/backend/web/index.php "
This is how one of the links is created:

$items[] = [
                'label' => \Yii::t('auth', 'Admin Panel'),
                'url' => '/admin/index.php'
            ];

Tell me how to make it so that both on the server and locally everything worked fine from any additional "crutches"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Petrik, 2016-05-30
@Paromon

It looks like your local web server is misconfigured. Do something like this
Root folder for Frontend: "/dom/frontend/web"
Root folder for Backend: "/dom/backend/web"
And, accordingly, approximately the following domain names (in hosts):
Frontend: dom.loc
Backend: admin .dom.loc
And, by the way, you don't generate urls correctly either. It is necessary like this:
I.e. without ".php"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question