Routes with wildcard (:any) ignoring other controllers

Asked

Viewed 55 times

2

In the archive Routes.php I defined the following route:

$route['(:any)'] = 'reference/check/$1';

I need it because the first parameter in the URL after the domain is the username (exemplo.com/{nome_usuario}). Then I perform checks on the Reference class.

The problem is that in this case all the others Controllers were inaccessible, all being overwritten by the route rule as shown above.

As a temporary solution I had to force others Controllers defining Routes for them as well, being as follows:

$route['home'] = 'home';
$route['login'] = 'login';
$route['register'] = 'register';
$route['(:any)'] = 'reference/check/$1';

Is there any alternative I can use so I don’t need to set new ones Routes whenever I create a new Controller?

1 answer

0

So far, there is no alternative. Since the tag (:any) serves precisely to accept anything, you will need to inform which routes you want to keep as controller rather than redirect.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.