开发者

CodeIgniter 2 - use default controller function without specifying in URL

开发者 https://www.devze.com 2023-02-08 17:36 出处:网络
Please see the following controller in CodeIgniter 2 <?php class user extends CI_Controller { function __construct() {

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

精彩评论

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