コントローラーをロードし、URIに基づいて関数を呼び出さないようにしたいので、次のセグメントに基づいてページを生成できます。これを行うためにデフォルトの動作を変更するにはどうすればよいですか?例えば。
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
}
}