L
L
lilwings2019-12-27 14:48:59
Yii
lilwings, 2019-12-27 14:48:59

cnc not working in yii2?

urlManager:

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'enableStrictParsing' => false,
    'rules' => [
        '' => 'index/index',
        'info' => 'info/info',
        'news' => 'news/news'
    ],
]

IndexController:
class IndexController extends Controller
{
    public function actionIndex() {
        return $this->render('index');
    }
}

InfoController:
class InfoController extends Controller
{
    public function actionInfo() {
        return $this->render('info');
    }
}

NewsController:
class NewsController extends Controller
{
    public function actionNews() {
        return $this->render('news');
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lilwings, 2019-12-27
@lilwings

When including urlManager, you need to add urlManager:

'request' => [
            'baseUrl' => '',
            'cookieValidationKey' => '...',
        ],

D
dblearn94, 2019-12-27
@dblearn94

Rule priority is not correct.
At you the first rule approaches for all requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question