开发者

Defining a default controller for a folder in Codeigniter

开发者 https://www.devze.com 2023-03-04 07:56 出处:网络
Hey everyone, I have my Codeigniter controllers set up in a folder called employees. The issue is that I don\'t seem to know the best way to specify the default controller if only the folder is typed

Hey everyone, I have my Codeigniter controllers set up in a folder called employees. The issue is that I don't seem to know the best way to specify the default controller if only the folder is typed in the URL. For instance, I would like to be able to type in:

www.mysite.com/employees

and have it d开发者_运维百科efault to the personnel controller, instead of having to type in:

www.mysite.com/employees/personnel

Any ideas? Thanks.


How have you specified it in your routes.php? Have you tried with:

$route['default_controller'] = "personnel";


Simple - just add an "index()" function

class Employees extends CI_Controller
{
    public function index()
    {
        redirect ('employees/personnel');
    }

    public function personnel()
    {
        // your code here
    }
 }
0

精彩评论

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