Multi Controller Name for an Url Rule?

I want to use like this url rule:{CategoryName}{NewsName}

Then i added into frontend/config/main.php;

‘<seo:[\w-]+>’ => ‘news/index’,

‘<seo:[\w-]+>’ => ‘category/index’,

But this isn’t working that’s normal, I know, but i need this, i have to do, do you know about this something? How can i do?

Thanks for everything.


$CategoryDetails = Category::findOne([‘category_seo’ => $seo]);

if (is_null(&#036;CategoryDetails)) {

    &#036;News = Yii::&#036;app-&gt;createControllerByID('news');

    return &#036;News-&gt;actionIndex(&#036;seo);


    throw new NotFoundHttpException('Sayfa Bulunamadı.');


That is not a good design unless you make sure that the user cannot create News and Category with the same name otherwise only the category is accessible. The normal way is to have the controller in the URL so you should stick to that unless you have a very good reason not to.

I did on NewsController with Cache. Bcs I have a little category. So, I keep categories in cache. Then that’s ok.