softboxkid softboxkid - 4 months ago 11
PHP Question

Codeigniter - Hide controller name. Just show parameter

I need to hide my controller name from being shows in the URL. Currently this is the URL www.example.xyz/page/information-technology-and-human

my route file is like this:

$route['page/(:any)'] = "frontend/$1";
$route['login'] = "frontend/login";


I want to remove the "page" in the URL. So it should be like this:

www.example.xyz/information-technology-and-human


How to do this. Please help me. Is it possible to do that?

Answer

Use this, as the last route defined in the routes.php file. It's important to define this wildcard route as the last route.

$route['(:any)'] = "frontend/$1";