evstevemd
(Stefano Mtangoo)
1
In Yii1.x all we had to do was add path something like’
urlManager'=>array( 'urlFormat'=>'path', ............. )
But in Yii2 its gone. How do I make my URLs without query-string something like
http://example.com/forum/post/id/2014/make-yii2-work
jacmoe
(Jacob Moen)
2
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
evstevemd
(Stefano Mtangoo)
3
Its not working giving url like
http://localhost/web/forum/topic?id=3
instead of
http://localhost/web/forum/topic/id/3
evstevemd
(Stefano Mtangoo)
4
Here is my URLManager components in config
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
//'enableStrictParsing' => true,
'rules' => [
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],
evercode
(Ikon321)
5
Try changing to:
'urlManager' => [ 'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => [
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:\w+>/<id:\d+>/<slug:[A-Za-z0-9 -_.]+>' => '<controller>/view',
],
This is tested and working for me.
evstevemd
(Stefano Mtangoo)
6
No it does not work either. Any reason why path was removed? I found it useful.
Any Discussion in GitHub that documents it?
timmy78
(Timothee Planchais)
7