title: codeigniter how to set routes to default controller according to the no of uri segments
body: <p>I am using codeigniter as a module in my project to display information as categories and its items.</p>
  
  <p>I want the url's like the following</p>
  
  <ol>
  <li>sitename.com/module/ will display all items in random order.</li>
  <li>sitename.com/moduel/categoryname/ will display all items in that specific category</li>
  <li>sitename.com/module/categoryname/title-of-the-item/ this will display the details of that specific item</li>
  </ol>
  
  <p>here sitename.com/module/ is the root of the codeigniter and the default controller is home.</p>
  
  <p>my question is how to set routes for one segment or uri and two segments of uri like</p>
  
  <ol>
  <li>sitename.com/module/ should load default controller(home in my case)</li>
  <li>sitename.com/module/categoryname/ should load home/category/categoryname</li>
  <li>sitename.com/module/categoryname/title-of-the-item should load index/title/title-of-the-item</li>
  </ol>
  
  <p>i will have defined my functions as follows</p>
  
  <ol>
  <li>funciton index() ...</li>
  <li>function category($categoryname) ....</li>
  <li>function title($title)....</li>
  </ol>
  
  <p>so, either i want to create a route according to the num of segments or if there is any other alternate to accomplish this with routing then that is fine.</p>
  
  <p>I want to do it using the routing and not by passing the 2 segments as arguments to Index function.</p>
  
  <p>so, ?</p>