How to remove controller name from url making it clean in codeigniter

后端 未结 9 1331
余生分开走
余生分开走 2020-12-20 16:50

I have the following url..

http://localhost/ci/site_controller/home

I want to remove site_controller controller

9条回答
  •  星月不相逢
    2020-12-20 17:19

    Drop the 'ci' from your routes. That is your project name and is never required. Routes always start on the controller level:

    $route['home'] = "site_controller/home";
    

    Will work. However, more importantly.. are you sure your design is correct? Why not just let home be a controller? Create a /application/controllers/home.php and you'll be able to access it's index() function with http://localhost/ci/home.

    You're complicating things. No need for routes at all.

提交回复
热议问题