![]() |
Remove controller name from the URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Remove controller name from the URL (/showthread.php?tid=76188) |
Remove controller name from the URL - eleumas - 04-20-2020 Hi, i would like remove the controller name from the URL. I have tried with the routes but i failed. I have this URL: domain.com/main/privacy and i would like transform it in: domain.com/privacy Thanks for help me! ![]() RE: Remove controller name from the URL - jreklund - 04-20-2020 Hi, you type your route like this: PHP Code: $routes->add('privacy', 'Main::privacy'); If you only wan't the method privacy to work. RE: Remove controller name from the URL - eleumas - 04-21-2020 Hi! Thanks for your answer. I tried your code but doesn't work ![]() In codeigniter 3 i used this routes for remove the controller name from the URL: PHP Code: $route['default_controller'] = 'main'; In codeigniter 4 what routes i have to use for remove MAIN (the controller name) from the URL? This is my Routes.php file. PHP Code: /** Thanks ![]() RE: Remove controller name from the URL - Gary - 04-21-2020 Try setting $indexPage='' (in \app\Config\App.php). RE: Remove controller name from the URL - eleumas - 04-21-2020 (04-21-2020, 06:47 AM)Gary Wrote: Try setting $indexPage='' (in \app\Config\App.php). I'm sorry, your code doesn't work ![]() RE: Remove controller name from the URL - jreklund - 04-21-2020 To redirect everything you need an any rule. PHP Code: $routes->add('(:any)', 'Main::$1'); And the previous provided routes work just fine. You most likely made an error in your Main.php file. RE: Remove controller name from the URL - eleumas - 04-22-2020 Now is all ok! Thanks. |