Yii url manager只有ID在URL [英] Yii url manager only ID in url
问题描述
我在YII例如域: www.example.eu/product-url-1234
如何在urlManager中设置规则以及如何使用 controller / action / id
如果您要使用此网址 www.example.eu/product-url-1234
假设'index'
是将处理请求的'user'
控制器的操作名称
然后创建一个类似
的规则 '< id:。*?& >'user / index'
现在,如果您将使用 Yii :: app() - > createUrl ('user / index',array('id'=>'product-url-1234'))
如果您访问此网址,用户/索引
将处理该请求。 p>
i have in YII for example domain: www.example.eu/product-url-1234
how to set rules in urlManager and how to use controller/action/id
If you want to use this url www.example.eu/product-url-1234
and suppose 'index'
is the name of the action of the 'user'
controller that will handle the request
Then create a rule like
'<id:.*?>'=>'user/index'
Now if you will use Yii::app()->createUrl('user/index',array('id'=>'product-url-1234'))
then it will give you the desired result.
And if you Visit this Url, User/Index
will handle the request.
这篇关于Yii url manager只有ID在URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!