CodeIgniter Forums
CI4 - Routing problem - 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: CI4 - Routing problem (/showthread.php?tid=76058)



CI4 - Routing problem - haunui - 04-11-2020

Hi,
When i load the URL that supposed to show my page, the server give me a 404 not found error. I added my routes on the app/Config/Routes.php file. I tried to add my routes before the default route ($routes->get("/")Wink, that doesn't help.

My routes :
Code:
$routes->get('/', 'Home::index');
$routes->add('hebergement', 'Home::hebergement');
$routes->add('prestations', 'Home::prestations');
$routes->add('activites', 'Home::activites');
$routes->add('contact', 'Home::contact');

How can i solved that ?


RE: CI4 - Routing problem - stlake2011 - 04-11-2020

(04-11-2020, 06:36 AM)haunui Wrote: Hi,
When i load the URL that supposed to show my page, the server give me a 404 not found error. I added my routes on the app/Config/Routes.php file. I tried to add my routes before the default route ($routes->get("/")Wink, that doesn't help.

My routes :
Code:
$routes->get('/', 'Home::index');
$routes->add('hebergement', 'Home::hebergement');
$routes->add('prestations', 'Home::prestations');
$routes->add('activites', 'Home::activites');
$routes->add('contact', 'Home::contact');

How can i solved that ?

https://codeigniter.com/user_guide/incoming/routing.html#using-http-verbs-in-routes

Try changing this: 
PHP Code:
$routes->add('hebergement''Home::hebergement'); 
to this:
PHP Code:
$routes->get('hebergement''Home::hebergement'); 
 
and maybe add a / as well here:

PHP Code:
$routes->get('/hebergement''Home::hebergement'); 



RE: CI4 - Routing problem - haunui - 04-11-2020

my bad i just missconfigured my apache server


RE: CI4 - Routing problem - Rose101 - 09-22-2022

(04-11-2020, 08:53 AM)haunui Wrote: my bad i just missconfigured my apache server

Hi, could you explain how you misconfigured the server, I'm having the same issue on an apache server