Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在yii URL管理器中更改友好URL的规则_Url_Yii_Url Rewriting_Yii Url Manager - Fatal编程技术网

在yii URL管理器中更改友好URL的规则

在yii URL管理器中更改友好URL的规则,url,yii,url-rewriting,yii-url-manager,Url,Yii,Url Rewriting,Yii Url Manager,我有一个需要两个参数的控制器 public function actionIndex($type = 'recent-jokes',$offset = 0) // rest of codes 我希望URL是这样的,这样它就可以从URL获取参数 something.com/items/type/offset 现在这是我在main.php中的配置 'rules'=>array( ''=>'items/index', '<controller:\w+>/

我有一个需要两个参数的控制器

 public function actionIndex($type = 'recent-jokes',$offset = 0)
 // rest of codes
我希望URL是这样的,这样它就可以从URL获取参数

something.com/items/type/offset

现在这是我在main.php中的配置

 'rules'=>array(
    ''=>'items/index',
    '<controller:\w+>/<action:\w+>/<id:\w+>'=>'<controller>/<action>',
    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
“规则”=>数组(
''=>'项目/索引',
'//'=>'/',
'/'=>'/',
),
你能帮我吗:)
非常感谢这个很棒的社区

规则=>数组(
 'rules'=>array(
    'items/<type:\w+>/<offset:\w+>' => 'items/index',
    /* other rules */
  ),
'项目/'=>'项目/索引', /*其他规则*/ ),

好了。

还有一个小问题,如何在视图中获取偏移量的值?您可以将该值传递给控制器中的视图