CodeIgniter Forums

Full Version: [split] Routing Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Glad to hear an update from CI 2.x Series. And wanna ask about routing. First, i dunno which thread exactly to ask this question, so sorry if i got wrong thread here. As i'm using CI 2.2.1 and this is a thread that newest from it's series so i ask here.

Second, sorry for my bad english. I'm from indonesia and still understanding to develop using this framework.

And here's my question, i'm playing with route. Like this below :

$route['(:any)'] = 'smpht/index/page/$1';

it explained that any first segment will routed to smpht controller, index method, and page as first param. How i can tell the CI to search controller first, than if there's no controller it will routed. like example below :


first it will find 'lorem' controller, when 'lorem' controller doesn't exist it will routed to :


if there's anyone knows the answer, i'm totally happy to hear the solution. thanks before.
Have you tried to use _remap function?
Just check the first segment of the url then you can make a condition where you want to pass them.

public function _remap(){
$segment_1 = $this->uri->segment(1);
$segment_2 = $this->uri->segment(2);

switch ($segment_1) {
case 'lorem':
//condition here..

hope it help Smile