noviceRick
noviceRick

Reputation: 121

codeigniter route removing function_name in url

I got stack on this in Codeigniter route, What do I want is to remove the function_name in url to be able to have a short url.

Here is the example want to have in my url

http://mysite.com/controller_name/function_name/id

to this

http://mysite.com/controller_name/id

Is there any other solution to have this if cannot be done in route? thanks!

Upvotes: 0

Views: 1348

Answers (2)

JD Guzman
JD Guzman

Reputation: 378

If the above didn't work you could try:

$route['controller_name/(:num)'] = 'controller_name/lookup_function/$1';

Not much different from what was already suggested other than a hard coded controller name.

Upvotes: 1

Jorge Guberte
Jorge Guberte

Reputation: 11064

You can probably do it by trying:

$route['([a-z]+)/(\d+)'] = "$1/method/$2";

That is if you don't need to change the name of your method.

Upvotes: 0

Related Questions