how to create Codeigniter route that doesn't override the other controller routes?

后端 未结 2 582
情书的邮戳
情书的邮戳 2021-02-10 05:14

I\'ve got a lot controller in my Codeigniter apps, ex: Signup, Profile, Main, etc..

Now I want to build \"User\" controller.

what I want:

<
2条回答
  •  离开以前
    2021-02-10 05:52

    You're going to have to explicitly define all of those routes. Otherwise you will always end up at the "user_controller".

    $route['signup'] = "signup";
    $route['(:any)'] = "user/display/$1";
    

    or something similar. They are ran in order, so what ever is defined first, is going to happen first. So if you catch (:any), you're going to send ANYTHING to that controller.

    Also keep in mind that you can use regular expressions, so if you know there is always going to be a '.' in there, you could test for that.

提交回复
热议问题