Welcome Guest, Not a member yet? Register   Sign In
Remove controller name from the URL
#3

(This post was last modified: 04-21-2020, 02:59 AM by eleumas.)

Hi! Thanks for your answer. I tried your code but doesn't work  Undecided
In codeigniter 3 i used this routes for remove the controller name from the URL:

PHP Code:
$route['default_controller'] = 'main';
$route['(:any)'] = "main/$1"

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:
/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Main');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(true);
$routes->set404Override();
$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.

// $routes->get('/', 'Main::index');
$routes->add('privacy''Main::privacy'); 

Thanks  Smile
Reply


Messages In This Thread
Remove controller name from the URL - by eleumas - 04-20-2020, 11:04 AM
RE: Remove controller name from the URL - by eleumas - 04-21-2020, 02:58 AM
RE: Remove controller name from the URL - by Gary - 04-21-2020, 06:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB