Codeigniter Guidelines

I need a codecode, so all of the following URLs:

admin/users/page/:num
admin/accounts/page/:num
members/results/page/:num
products/page/:num

are sent to

admin/users/index
admin/accounts/index
members/results/index
products/index

respectively. I would like only one regex that could do the trick, not me, setting routes manually each time.

To be specific, any URL that ends with page/:nummust be redirected to the appropriate controller index method. And by :numI mean any number.

Is it possible?

+3
source share
1 answer

I really don't understand why you would like to do this. (I assume you want to get the page number from the url)

system/application/config/routes.php ( ):

$route['([a-z]+)/page/:num'] = "$1/index";
$route['([a-z]+)/([a-z]+)/page/:num'] = "$1/$2/index";

cmiiw.

+4

Source: https://habr.com/ru/post/1712185/


All Articles