Welcome Guest, Not a member yet? Register   Sign In
Routes and other things....
#1

[eluser]bronet[/eluser]
Hi,

I'm working on a tvshow manager app and I do have some questions. I want to have urls like this:
Quote:TVShow Info: http://localhost/show/1-white-collar/
Season Info: http://localhost/show/1-white-collar/season-1/
Episode Info: http://localhost/show/1-white-collar/sea...s-a-title/

And I use these rules in routes.php
Code:
$route['show/(:num)-(:any)/season-(:num)/ep-(:num)-(:any)'] = "manager/index/$1/$2/$3/$4/$5";
$route['show/(:num)-(:any)/season-(:num)'] = "manager/index/$1/$2/$3";
$route['show/(:num)-(:any)'] = "manager/index/$1/$2";

But.. when I acces: http://localhost/show/1-white-collar/hjhfjdhfh
I receive something like this from $this->uri->rsegment_array(); (instead of 404 error)
Code:
Array ( [1] => manager [2] => index [3] => 1 [4] => white-collar [5] => hjhfjdhfh )

Or.. when I access: http://localhost/show/1-white-collar/season-dgfgfg/
I receive this: (instead of 404 error)
Code:
Array ( [1] => manager [2] => index [3] => 1 [4] => white-collar [5] => season-dgfgfg )

What can be wrong in my routes rules ?
#2

[eluser]John_Betong_002[/eluser]
Try this:

./application/config/routes.php
Code:
$route["show"]                              = "manager";            
  $route["show/(:any)"]                       = "manager/index/$1";  
  $route["show/(:any)/(any)"]                 = "manager/index/$1/$2";  
  $route["show/(:any)/(:any)/(:any)"]         = "manager/index/$1/$2/$3";
  $route["show/(:any)/(:any)/(:any)/(:any)"]  = "manager/index/$1/$2/$3/$4";

 
 
// ./application.controllers/Manger.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

//==================================================
class Manager extends CI_Controller
{

//==================================================
function index()
{
  
  echo '<dl>';
    echo '<dt>function:</dt>';
      echo '<dd>index() <br /><br /></dd>';

    echo '<dt>URI: </dt>';
      echo '<dd>' .$this->uri->uri_string() .'<br /><br /></dd>';
  
    echo '<dt>Segments</dt>';
      foreach($this->uri->segment_array() as $seg):
        echo '<dd>' .$seg .'</dd> ';
      endforeach;
  echo '</dl>';
}//endfunc

//==================================================
function white_collar()
{
  //
}//endfunc

}//endclass
&nbsp;
No doubt there may be better ways but at least this will get you started Smile
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB