создал свое правило
<?php
namespace frontend\components\rules;
use Yii;
use yii\web\UrlRuleInterface;
use yii\base\BaseObject;
use common\models\InfoPage;
class InfoPageUrlRule extends BaseObject implements UrlRuleInterface
{
//public $route = 'infoPage/page';
public function createUrl($manager, $route, $params)
{
Yii::info($route);
if ($route == 'infoPage/page/' && !empty($params['id'])) {
//$url = false;//Yii::$app->cache->get('category-' . $params['id']);
//if (!$url) {
$infoPage = InfoPage::find()->where(['id' => $params['id']])->one();
if (!$infoPage) {
return false;
}
$url = '/' . $infoPage->slug.'/';
//Кэш на 3 часа
//Yii::$app->cache->set('category-' . $params['id'], $url, 10800);
//}
$param = '';
if (!empty($params['filter'])) {
foreach ($params['filter'] as $k => $v) {
$param .= ($param == '' ? '?' : '&') . $k . "=" . $v;
}
}
return $url . $param;
}
return false;
}
public function parseRequest($manager, $request)
{
if (empty($request->getPathInfo())) {
return false;
}
$infoPage = InfoPage::find()->where(['slug' => str_replace('/','',$request->getPathInfo()),])->one();
if ($infoPage) {
return ['infoPage/page', ['id' => $infoPage->id]];
}
Yii::info($infoPage);
return false;
}
вот так подключил его в config/main.php
'urlManager' => [
'class' => 'codemix\localeurls\UrlManager',
'languages' => ['en', 'ru'],
'enablePrettyUrl' => true,
'showScriptName' => false,
'suffix' => '/',
'rules' => [
['class' => 'frontend\components\rules\InfoPageUrlRule'],...
но при переходе на правильно сформированную ссылку получаю такую ошибку
11:52:10.977 trace yii\web\Application::handleRequest Route requested: 'infoPage/page'
11:52:10.978 error yii\web\HttpException:404 yii\base\InvalidRouteException: Unable to resolve the request "infoPage/page". in /var/www/tiger.lc/vendor/yiisoft/yii2/base/Module.php:537
Почему не подскажите ?