Codeigniter Routes regex - using dashes in controller/method names

前端 未结 9 1245
小鲜肉
小鲜肉 2020-11-29 01:32

I\'m looking for a one line route to route dashed controller and method names to the actual underscored controller and method names.

For example the URL



        
9条回答
  •  借酒劲吻你
    2020-11-29 01:44

    
    

    Put this file MY_Router.php inside /application/libraries (CI1) or /application/core (CI2) Remember that this will effect all segments, not only module, controller and method.

    Alternative to this extend is to add each segment to router.php $route['this-is-a-module-or-controler'] = 'this_is_a_module_or_controller';

    As you can see the extend method would be easier to use. You can choose to make the function also to handle only the first two or three segments so that the other segments are not affected with the _ replacement.

提交回复
热议问题