sg web
sg web

Reputation: 11

I want to remove controller as well as function name from url

I need help to rewrite url and remove controller as well as function name from url given url is my current uel.

URL :http://localhost/example/Loadercontrol/detail/200

I want this type of url

URL : http://localhost/example/name (replace id with name).

I already try rewrite url as well as

$route['example'] = 'localhost/example/Loadercontrol/detail';  

but it's not working. I've really tried to fix the issue. Please help me.

Upvotes: 1

Views: 48

Answers (1)

Hikmat Sijapati
Hikmat Sijapati

Reputation: 6994

Try like this..

$route['example/(:num)'] = 'example/Loadercontrol/detail/$1';

For details see more here...https://www.codeigniter.com/userguide3/general/routing.html#wildcards

Wildcards are actually aliases for regular expressions, with :any being translated to [^/]+ and :num to [0-9]+, respectively.

Upvotes: 1

Related Questions