Walker
Walker

Reputation: 134701

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 (/login, /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.

Upvotes: 2

Views: 365

Answers (2)

Aaron W.
Aaron W.

Reputation: 9299

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

Upvotes: 1

Pawan Choudhary
Pawan Choudhary

Reputation: 1083

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.

Upvotes: 2

Related Questions