I need to do some changes in vendor/yiisoft/yii2/web/urlmanager.php for my url_alias to work! I need to know if I can change this file directly or is there any method to override this file?
Best way is to create new URL Manager Class that extends existing UrlManager class i.e. yii/web/urlManager.php
i.e
class customUrlManager extends yii/web/urlManager {
.. code here
}
Then specify the class in your config element i.e frontend/config/main.php
'urlManager' => [
'class' => '<name_space>/customUrlManager'
'enablePrettyUrl' => True,
'showScriptName' => False,
'rules' => [
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With