T
T
thevataman2015-08-09 12:40:40
Yii
thevataman, 2015-08-09 12:40:40

How to implement such a cnc in yii2?

How to make it so that when you go to the link:
www.site.ru/vasia - the personal page of the user Vasya
opens www.site.ru/news - the page of the site news opens.
The site is being developed on yii 2.
Users will share links to their profiles, it is necessary that they be as simple as possible.
As for the url of other sections of the site, it does not matter how they will look.
While there is one idea, check what is after / in the database. If there is no such user, then show the news page or something. But this is somehow wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2015-08-09
@thevataman

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,

            'rules' => [
                '/news' => 'news/index', //Таких правил придётся делать на все подобные страницы
                '/<user>' => 'user/view',
            ]
        ],

In the user model, it is natural not to allow the possibility of creating a news login and the like.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question