Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.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中隐藏参数?_Yii - Fatal编程技术网

我们如何在yii框架的url中隐藏参数?

我们如何在yii框架的url中隐藏参数?,yii,Yii,对不起,我是新的bie,我在Yii框架中使用友好的url。索引页是可以的,但当我输入参数进行编辑时,url不友好 索引页:http://localhost/news/news/index.html 编辑页面:http://localhost/news/news/edit/59.html 我们如何隐藏id参数并具有如下url: http://localhost/news/news/edit.html 下面是main.php中的配置 'urlManager'=>array(

对不起,我是新的bie,我在Yii框架中使用友好的url。索引页是可以的,但当我输入参数进行编辑时,url不友好

索引页:
http://localhost/news/news/index.html

编辑页面:
http://localhost/news/news/edit/59.html

我们如何隐藏id参数并具有如下url:

http://localhost/news/news/edit.html

下面是main.php中的配置

'urlManager'=>array(
            'urlFormat'=>'path',    
            'showScriptName' => false,
            'urlSuffix'=>'.html',                   
            'rules'=>array(         
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ),
        ),
'urlManager'=>数组(
“urlFormat'=>“路径”,
'showScriptName'=>false,
'urlSuffix'=>'.html',
'规则'=>数组(
“/”=>“/视图”,
'//'=>'/',
'/'=>'/',
),
),

非常感谢

您必须在url上附加某种形式的标识符来表示唯一的记录。如果你想去掉ID,可以使用标题或文本来达到让URL搜索引擎友好的目的。如果你要走那条路线,你必须设置一个自定义url规则。 有关更多信息,请参阅