![]() |
Route wont work - 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: Route wont work (/showthread.php?tid=92261) Pages:
1
2
|
Route wont work - 4usol - 01-02-2025 Hi, i try to run a simple redirection but i failed. Code: redirect('access_denied/index/myval'); it should rout to the controller in my base-folder "access_denied" to the funtion "index" and the values for the index-function with "myval". routes.php Code: $routes->get('access_denied', '\App\Controllers\Access_denied::index'); //no result ->The route for "access_denied/index/myval" cannot be found What i'm doing wrong? Update The Route: $routes->get('accessdenied/(:any)', 'Access_denied::index/$1'); dont work like it should be, i will always redirect to the shield/login page - maybe there is a problem with the settings about the shield-routes? in the Filter Config is this: Code: public array $globals = [ if i comment this line out, the route seems to work. Now i ask myselt how i can change the filter. I want that all pages avivable outside a subfolder in the controllers named "myadminarea" this folder should be only accessable for loggedin users. RE: Route wont work - captain-sensible - 01-02-2025 take out Code: \App\Controllers\ and see if it helps, i think underscore is an allowed character although i would have written it camel case accessDenied RE: Route wont work - 4usol - 01-02-2025 thanks i've update my code above, the problems seems to comes from the filter-config. May you have a look at this? RE: Route wont work - michalsn - 01-02-2025 Adding access_denied* to the list should work PHP Code: public array $globals = [ RE: Route wont work - 4usol - 01-02-2025 Ok, but is there still a way to change the way it works? At the moment all pages will "protected" i've not defined in the "except" Array. Much easier for me it will be if i - define a subfolder to protect - with all possible controllernames etc as a kind of wildcard "myfolder/*" - all other pages wont protected and rund only like defined in the routes Update I decide to use the filter function not and add a own function to every page. Now i need a bit help to create a dynamic routes for the logged-in area. I cannot define all possible routes, so i need to create a flexible route how works for all possible url-combinations The idear will be something like that: $routes->get('myfolder/(:alphanum)/(:alphanum)/(:alphanum)/(:alphanum)', '\App\Controllers\Myfolder\$1\$2$\$3\$4'); But this failed, is it possible to do something like that? RE: Route wont work - michalsn - 01-02-2025 In that case, remove the entire session key and go down to the $filters property: PHP Code: public array $filters = [ RE: Route wont work - 4usol - 01-02-2025 Great, but now i've decide to use the filter function not and add a own function to every page. Now i need a bit help to create a dynamic routes for the logged-in area. I cannot define all possible routes, so i need to create a flexible route how works for all possible url-combinations The idear will be something like that: $routes->get('myfolder/(:alphanum)/(:alphanum)/(:alphanum)/(:alphanum)', '\App\Controllers\Myfolder\$1\$2$\$3\$4'); But this failed, is it possible to do something like that? RE: Route wont work - michalsn - 01-02-2025 Not a good idea. Just go with auto routing improved. RE: Route wont work - 4usol - 01-02-2025 After enable the autoroute, my shield login wont work corretly. For example the routes for "auth/a/handle" etc. runs into a 404-error. May i have to go back to the beginning to create a kind of dynamically route... ...or is it possible to cretae the entries in the route.php dynmically after login by values from database (i have diffrent modules (with diffrent url-syntax) wich users can en/disable, for that i looking for a easy but flexible way) RE: Route wont work - michalsn - 01-02-2025 Do you still have PHP Code: service('auth')->routes($routes); |