File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
CodeIgniter/Framework/core Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,21 @@ protected function _set_default_controller()
294294
295295 $ class ??= '' ;
296296
297+ // Trim '/index' from the end if present
298+ $ defaultController = preg_replace ('#/index$# ' , '' , $ this ->default_controller );
299+
300+ // Check if default controller is not 'app' or 'app/index'
301+ // AND if the route value contains 'prefix-route'
302+ if (
303+ $ this ->default_controller !== 'app '
304+ && $ this ->default_controller !== 'app/index '
305+ && str_contains ($ this ->routes [$ defaultController ], 'prefix-route ' )
306+ ) {
307+ $ baseUrl = $ this ->config ->config ['base_url ' ];
308+ // Redirect to the set default_controller with the base_url
309+ header ('Location: ' . $ baseUrl . $ this ->default_controller );
310+ }
311+
297312 if (! file_exists (COREPATH . 'controllers/ ' . $ this ->directory . ucfirst ($ class ) . '.php ' )) {
298313 // This will trigger 404 later
299314 return ;
Original file line number Diff line number Diff line change 22defined ('COREPATH ' ) or exit ('No direct script access allowed ' );
33
44use Base \Route \Route ;
5+ use Base \Route \HelperRoute ;
6+
57/*
68| -------------------------------------------------------------------------
79| URI ROUTING
7476$ GLOBALS ['default_routes ' ] = $ default ;
7577$ GLOBALS ['available_routes ' ] = $ route ;
7678
79+ // Initialize HelperRoute - this checks for matches
80+ HelperRoute::init ();
81+ $ route = array_merge ($ route ?? [], HelperRoute::getRoutes ());
82+
7783/**
7884 * Build routes
7985 */
You can’t perform that action at this time.
0 commit comments