开发者

Problems with dynamic routes in CodeIgniter

I'm trying to use personal URLs through the code of my application that function the same way as www.facebook.com/namehere (on my application www.website.com/identifier). How would you set this up in routes to be dynamic? So that if /identifier was not an existing controller (/log开发者_开发技巧in, /admin, /howitworks, /about are all taken) it runs a function and uses the identifier to query a database?

I've tried reading up on routing but I can't seem to get this working.


Just follow this url Codeigniter's url routing and __remap()

If your controller contains a function named _remap(), it will always get called regardless of what your URI contains. It overrides the normal behavior in which the URI determines which function is called, allowing you to define your own function routing rules.

Documentation of CI is very good, it will teach you everything in a very simple and elegent way.


You can set the 404_override in the routes config. Then checkout the _remap (link) function to route things within that controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜