Yii url manager只有ID在URL [英] Yii url manager only ID in url

查看:142
本文介绍了Yii url manager只有ID在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆