Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide controller name in the url in CodeIgniter?

so the thing is I'm using .htaccess to hide the index.php but I still get the controller name in the url like that: http://example.com/name_controller/about My question is: is it possible to hide the name of the controller, so that only method is shown? hxxp://example.com/name_controller/about

like image 396
qmmr Avatar asked Jun 07 '10 16:06

qmmr


People also ask

How to hide controller name in codeigniter?

You can add below code in the /application/config/routes. php file: $route['default_controller'] = "Home"; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; $route['(? i)about'] = "Home/about"; $route['(?

How to remove controller name from url in codeigniter 4?

HOW TO REMOVE CONTROLLER NAME FROM THE URL IN CODEIGNITER? here “home” is controller name and “member_register” is controller getmembers/method name. Now if we remove controller name from URL, it should work, http://localhost/ci/member_register.


1 Answers

You can define a custom route in config/routes.php - for example:

$route['about'] = 'name_controller/about';

Then, http://example.com/about
goes to http://example.com/name_controller/about

See Hiding the controller’s method name in the URL? in the CI forums for more information.

like image 170
Justin Ethier Avatar answered Nov 04 '22 16:11

Justin Ethier