hulei0102 发表于 2011-6-4 07:02:58

如何实现REST风格的URI?

http://example*com/customers/1234
http://example*com/products/4554
http://example*com/Author/作者名

上述这些uri对搜索引擎是相当的友好,而且结构也比较清晰。才使用1各月的ci,我似乎觉得ci并不能实现这种风格的uri。哪位达人搞过请指点一下。




hulei0102 发表于 2011-6-4 07:15:49

ci的uri设计原则是example.com/class/function/ID
想来想去只能是加个function才能解决问题啊,主题中的uri用ci来搞就只能是这样:
http://example*com/customers/ID/1234 在控制器中得有ID这个function
http://example*com/products/ID/4554 在控制器中得有ID这个function
http://example*com/Author/Name/作者名 在控制器中得有Name这个function

jeongee 发表于 2011-6-4 10:52:45

回复 hulei0102 的帖子

使用CI的router即可解决啊,或者使用rewrite也可以解决啊

lcnphp 发表于 2011-6-4 19:12:18

本帖最后由 lcnphp 于 2011-6-4 19:16 编辑

楼上正解

http://codeigniter.org.cn/user_guide/general/routing.html

visvoy 发表于 2011-6-5 16:05:08

你还要解决post跟put,get和delete是同一个uri的问题

lamtin 发表于 2011-6-6 00:45:59

http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/

cifans 发表于 2011-6-12 22:47:45

router
页: [1]
查看完整版本: 如何实现REST风格的URI?