0
votes

I have a controller Pages, am using this controller to load the product details and division details.

When am loading a division the URL loaded in the browser in the below manner

URL: www.example.com/pages/division_details/$1

but i need the URL to be loaded in the browser is

URL: www.example.com/$1

the controller and method name(pages/division_details) must be replaced and the $1 value i,e. the value which is obtained from the database will be loaded

same as in the case of product details

URL: www.example.com/pages/product_details/$1

URL: www.example.com/$1

the controller and method name(pages/product_details) must be replaced and the $1 value i,e. the value which is obtained from the database will be loaded

How should I place routing method so that i should not see the controller and method name in the URL ?

1
check the official document codeigniter.com/userguide3/general/routing.html and update your post what you did accordingly. - Deep 3015
updated the post @Deep3015 - Sairam Duggi
It is not possible same route for two action in CI. it can be define two route for your problem. - NikuNj Rathod
The only way of doing something like this is creating your own route handler where you check what's inside the $1 and then define where it belongs. However this is not recommended. - killstreet

1 Answers

0
votes

You may create it by using some text like

$route['division_(:num)'] = 'pages/division_details/$1';
$route['product_(:num)'] = 'pages/product_details/$1';

Now your URL will be something like

www.example.com/division_$1

and for product

www.example.com/product_$1