![]() |
404 default Controller Home 2nd method - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9) +--- Thread: 404 default Controller Home 2nd method (/showthread.php?tid=91134) |
404 default Controller Home 2nd method - TakonSix - 06-20-2024 Hi, i setup a new Project with CI4. app/Config/Feature.php PHP Code: public bool $autoRoutesImproved = true; app/Config/Routing.php PHP Code: public string $defaultController = 'Home'; app/Config/Routes.php PHP Code: <?php app/Controllers/Home.php PHP Code: <?php But i get a 404 on Https://xxxxx.de/Test with following error Quote:Cannot access the default controller "\App\Controllers\Home::getTest" What am i missing? I don't wanna write every route in app/Config/Routes.php Best regards. RE: 404 default Controller Home 2nd method - kenjis - 06-20-2024 The basic URL pattern is "https://example.com/class/method/arg" See https://codeigniter.com/user_guide/incoming/routing.html#uri-segments If you want to have "https://xxxxx.de/test", create Test::getIndex(). RE: 404 default Controller Home 2nd method - TakonSix - 06-21-2024 Thank you for your reply kenjis, I read the Docs, not 100% but 70-80% and i have some experience with some CI4 Projects, but never use the Default Controller with more methods. The following urls didn't work, but i dont know why not. Https://xxxxx.de/Home Quote:Cannot access the default controller "\App\Controllers\Home" with the controller name URI path.Https://xxxxx.de/Home/Test Quote:Cannot access the default controller "\App\Controllers\Home" with the controller name URI path. What am i missing or is it not possibly to have more than Index method in the default Controller? Best regards RE: 404 default Controller Home 2nd method - kenjis - 06-21-2024 (06-21-2024, 02:01 AM)TakonSix Wrote: is it not possibly to have more than Index method in the default Controller? No, it is not possible. Quote:Important RE: 404 default Controller Home 2nd method - kenjis - 06-21-2024 (06-21-2024, 02:01 AM)TakonSix Wrote: The following urls didn't work, but i dont know why not. That is for security reasons. Auto Routing Improved permits only one URI for a controller method. In this case, Home::getIndex() -> https://xxxxx.de/ (not https://xxxxx.de/home) RE: 404 default Controller Home 2nd method - TakonSix - 06-23-2024 (06-21-2024, 02:27 AM)kenjis Wrote:(06-21-2024, 02:01 AM)TakonSix Wrote: is it not possibly to have more than Index method in the default Controller? I am sorry that i read over this O.o Thank you for taking the time to explain this to me. RE: 404 default Controller Home 2nd method - kenjis - 06-23-2024 It is true that auto routing improved is a bit complex and difficult to understand. If you use it now, I recommend you enable $translateUriToCamelCase. See https://codeigniter.com/user_guide/incoming/controllers.html#translate-uri-to-camelcase Also, spark routes command may help you to understand. See https://codeigniter.com/user_guide/incoming/routing.html#spark-routes |