如何实现REST风格的URI?
http://example*com/customers/1234http://example*com/products/4554
http://example*com/Author/作者名
上述这些uri对搜索引擎是相当的友好,而且结构也比较清晰。才使用1各月的ci,我似乎觉得ci并不能实现这种风格的uri。哪位达人搞过请指点一下。
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
回复 hulei0102 的帖子
使用CI的router即可解决啊,或者使用rewrite也可以解决啊 本帖最后由 lcnphp 于 2011-6-4 19:16 编辑
楼上正解
http://codeigniter.org.cn/user_guide/general/routing.html 你还要解决post跟put,get和delete是同一个uri的问题 http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/ router
页:
[1]