Hi All,
I am coming to the line of thinking that I am missing something very simple here, but just cannot see it.
ON both my local MAMP environment on the Mac, and on a shared hosting platform, the following routing code is misbehaving. Allow_rewrite is switched on, and the .htaccess file is working. The code was developed initially with the alpha version of CI4, and now updated through Composer to CI4.0.4.
In /config/routes.php I have:
* Controllers when no specific route has been defined. If false,
* only routes that have been defined here will be available.
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$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('/', 'Home::index');
$routes->get('/dashboard', 'Users::dashboard', ['as' => 'dashboard']);
That works fine, and routes to the dashboard, with no index.php file in evidence and all is ok.
However, once the route definitions change to:
$routes->get('/', 'Home::index');
$routes->get('/dashboard/news/(:num)', 'Users::newsstory/$1');
$routes->get('/dashboard/account', 'Users::accountsettings');
$routes->get('/dashboard', 'Users::dashboard', ['as' => 'dashboard']);
Then the /dashboard route still works, but when you navigate to /dashboard/account - it says cannot find Users::account. When you navigate to /dashboard/news/11 is says cannot find Home::index.
Anything beyond the first level routing is mis-routing. Within the users controller are functions called dashboard, account settings and newsstory($storyid) but the latter two are never called. I can get the segment data by breaking down the URL in the code, but that does not solve the issue of routing.
Where am I going wrong can anyone tell me?
Rich