CodeIgniter Forums
CI4 - Routing problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: CI4 - Routing problem (/thread-76058.html)



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