I want to set Dynamic Routing
for url in Cms pages in yii2.
When i add Cms page i will add page alias aboutus,faq,management etc , these alias will saved in db
In addition to ck_arjun's answer, you can pass parameter to route as an ID. For example, if you want redirect "/aboutus" to "/site/page/id/2".
Replace:
$routeArray[$row->alias] = 'YOUR_ORIGINAL_URL'
in
$routeArray[] = ['class' => 'yii\web\UrlRule', 'pattern' => $row->alias, 'route' => $row->route, 'defaults' => ['id' => $row->id]];