开发者

CodeIgniter 2 - use default controller function without specifying in URL

Please see the following controller in CodeIgniter 2

<?php
class user extends CI_Controller {

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

    function index($id) {
        // do something here    
    }
}

?>

So my URL would be http://mydomain.com/user/index/2

But what I really want is to be able to not have the 'index' in the URL, so the URL would be http://mydomain.com/user/2

Does anybody know how I can achieve this?

Tha开发者_如何学编程nks in advance


My other answer is to get rid od the index.php, but I didn't realize that's not what you asked.

I have had to deal with this issue so what I did was add a regex number route:

$route['(:num)'] = '/user/index/$1';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜