简体   繁体   中英

Codeigniter rerouting doesnt except controllers

Hy i'm trying to do the same as was written in that question: Codeigniter: send all requests that do not match a controller's name to the default controller . So i'm trying to call a function when id doesn't match a controler name. So here is what i have done in confgi/routes:

$route['default_controller'] = "main";
$route['404_override'] = '';
$route['page/privacy-policy'] = "pages/privacyPolicy";
$route['u/(:any)'] = "profile/show/$1";
$route['(:any)'] = "login/show/$1";

So if i go to url

mypage.com/myname 

it goes to login/show which is fine, but problem is that if i type in

mypage.com/main

and it stils goes to the login/show. Any ideas how to owerride that behaviour?

And if i type in

mypage.com

it also goes to the login/show.

I think $route['(:any)'] will match any set of URI requests. If you want all your controllers to be secure you must Extend them from a SecureController and set the login verification check in that SecureController's constructor.

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