简体   繁体   中英

How to make all controller routes to default to index in the routes.php file

I have some controllers like home and welcome , now in my routes.php i have set the default controller to be:

$route['default_controller'] = 'home/index';

This works fine, now I want for all other controller to go to the default function of index without typing index in the url like.

http://localhost/codeigniterapp/index.php/welcome/

To do that I did this in the routes.php:

$route['welcome'] = "welcome/index";
$route['home'] = "home/index";
$route['xxx'] = "xxx/index";

Now I don't want to be doing that for every controller but would want something like a (:any) wildcart i saw in their userguide . I tried:

$route['(:any)'] = '(:any)/index';

But that did not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM