2011-02-10 90 views
1

我只是想加載控制器,而不是調用基於URI的函數,以便我可以基於以下段生成頁面。 如何更改默認行爲來執行此操作?例如。CodeIgniter - 關閉控制器函數調用?

example.com/class/function/ID >>> example.com/class/ID/ID

我以爲所有我需要做的是在config.php中添加:

$route['find/(:any)/(:any)'] = "find/$1/$2"; 

但是這給了我一個404


example.com/find/item/location

class Find extends CI_Controller { 

private $s1; 
private $s2; 

function __construct() 
{ 
    parent::__construct(); 
} 

function index() 
{ 
    $this->s1 = $this->uri->segment(2); 
    $this->s2 = $this->uri->segment(3); 
    $this->makePage(); 
} 

function makePage() 
{ 
    echo 'Page about ' . $this->s1 . 'in ' . $this->s2; 
    //Get Data ($s1 & $s2) 
    //Load View 
} 
} 

回答

相關問題