Yii2 give us the opportunity to customize URL rules as we want. This can be done using the
rules property in
urlManager, an array where keys are patterns and values are corresponding routes. Patterns are common regular expression patterns, so it is necessary to have some familiarity with regular expression.
Patterns can contain parameters that will be passed to the route. In the next example, we will display a list of news that can be filtered through year or category parameter, based on parameters passed to the URL.
In this example, we will create a new Controller named
controllers/NewsController.php. In this new controller, we will insert a
data() function containing an array ...