How do I customize URL in Yii2?
问题 I'm new in Yii2 so I have Brands table with their types ('brand', 'author', 'company') and their slug name so I need the URL like that www.site.com/{brand_type}/{brand_slug} without controller name so how to do that ? 回答1: This is commonly called pretty URLs. To do achieve that in Yii2 put this in your app config file under 'components' key 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ // ... '<type:\w+>/slug:\w+>' => 'yourcontroller/youraction', // ...